Home arrow static arrow Java Programming [Archive] - Vectors of Arrays - Please Help!
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - Vectors of Arrays - Please Help!
This topic has 18 replies on 2 pages.    « Previous | 1 | 2 |

Posts:61
Registered: 5/5/04
Re: Vectors of Arrays - Please Help!  
Jun 14, 2004 4:13 AM (reply 15 of 18)



 
Alright, this is bizarre. Apparently the problem is not in my method because once I did another print loop before the return statement it seems to be working just fine (thought I swear when I did this on Friday it was showing the same result every time...).

I'll now post the methods where this dbFetchRows method is called and perhaps my error is there.

Posting the entire methods is a bit superfluous but per your request I'll do it anyway.

private void print(Vector arrayVector) {        int j;        Vector printVector = new Vector();        String[] stringArray = new String[6];        for(int i = 0; i < arrayVector.size(); i++) {            j = 0;            for(int k = 0; k < ((String[])arrayVector.get(i)).length; k++) {                if((k == 0) || (k == 1) || (k == 2) || (k == 6) || (k == 8) || (k == 9)) {                    stringArray[j] = ((String[])arrayVector.get(i))[k];                    j++;                }            }                            printVector.add(stringArray);        }                PrintsModel pm = new PrintsModel();        for(int l = 0; l < printVector.size(); l++) {            pm.add((String[])printVector.get(l));        }                TablePrint table = new TablePrint(pm);                DefaultTableCellDrawer cellDrawer;        cellDrawer = table.createDefaultHeaderDrawer(PrintConstants.CENTER);        cellDrawer.getDrawer().setFont(new Font("Courier New", Font.BOLD, 10));        table.setDefaultHeaderDrawer(cellDrawer);                cellDrawer = table.createDefaultFooterDrawer(PrintConstants.RIGHT);        cellDrawer.getDrawer().setFont(new Font("Courier New", Font.BOLD, 10));        table.setDefaultFooterDrawer(cellDrawer);                cellDrawer = table.createDefaultCellDrawer(PrintConstants.CENTER);        cellDrawer.getDrawer().setFont(new Font("Courier New", Font.PLAIN, 10));        table.setDefaultCellDrawer(cellDrawer);                new PrintPreview(table).open();    }


and

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {        // Pressing the "Move" button        String conn1Driver = jTextField1.getText();        String conn1URL = jTextField2.getText();        String conn1Username = jTextField3.getText();        String conn1Password = jTextField4.getText();        String table = jTextField5.getText();        String conn2Driver = jTextField6.getText();        String conn2URL = jTextField7.getText();        String conn2Username = jTextField8.getText();        String conn2Password = jTextField9.getText();                Connection conn1 = EZdb.openDB(conn1Driver, conn1URL, conn1Username, conn1Password);        Connection conn2 = EZdb.openDB(conn2Driver, conn2URL, conn2Username, conn2Password);                if(conn1 == null) {            jDialog1.pack();            jDialog1.show();            jTextField1.setText("");            jTextField2.setText("");            jTextField3.setText("");            jTextField4.setText("");        }                if(conn2 == null) {            jDialog2.pack();            jDialog2.show();            jTextField6.setText("");            jTextField7.setText("");            jTextField8.setText("");            jTextField9.setText("");        }                if((conn1 != null) && (conn2 != null)) {            String SQLStatement1 = "select * from " + table;            Vector sourceVector = EZdb.dbFetchRows(conn1, SQLStatement1);            for(int i = 0; i < sourceVector.size(); i++) {                String updateStatement = "insert into " + table + " values(";                for(int j = 0; j < ((String[])sourceVector.get(i)).length; j++) {                    if(j == ((String[])sourceVector.get(i)).length - 1) {                        updateStatement += '\'' + ((String[])sourceVector.get(i))[j] + "')";                    }                    else {                        updateStatement += '\'' + ((String[])sourceVector.get(i))[j] + "',";                    }                }                System.out.println(updateStatement);                EZdb.dbUpdateRecord(conn2, updateStatement);            }        }    }
 

Posts:61
Registered: 5/5/04
Re: Vectors of Arrays - Please Help!  
Jun 14, 2004 4:15 AM (reply 16 of 18)



 
Actually in the first method, print, when a button is pressed in the GUI a vector is set as the results of dbFetchRows and passed to print().
 

Posts:61
Registered: 5/5/04
Re: Vectors of Arrays - Please Help!  
Jun 14, 2004 11:26 AM (reply 17 of 18)



 
Ha! I figured it out. Just needed to define the stringArray inside the first for loop. :-P

Thanks for your help, though. :)
 

Posts:37,103
Registered: 3/30/99
Re: Vectors of Arrays - Please Help!  
Jun 14, 2004 12:53 PM (reply 18 of 18)



 
Ha! I figured it out. Just needed to define the
stringArray inside the first for loop. :-P

Thanks for your help, though. :)

Cool, glad you got it. :-)
 
This topic has 18 replies on 2 pages.    « Previous | 1 | 2 |