--- FM2SQL/Attic/Convert.java 2004/01/16 11:23:49 1.13 +++ FM2SQL/Attic/Convert.java 2004/01/20 21:16:10 1.18 @@ -393,12 +393,13 @@ class Convert int size = bean.getColumnNames().size(); for (int i = 0; i < size - 1; ++i) - command.append(convertText((String)bean.getColumnNames().get(i))+" = ? "); + command.append(beanDest.getQC()+convertText((String)bean.getColumnNames().get(i))+beanDest.getQC()+" = ? ,"); command.append(convertText((String)bean.getColumnNames().get(size-1))+" = ? "); + command.append("WHERE "+convertText(ids.get(tbIndex).toString())+ " = ?"); PreparedStatement pstm = beanDest.getConnection().prepareStatement(command.toString()); - System.out.println(command); - System.exit(0); + System.out.println(command+" "+tbIndex); int rowCount = bean.getRowCount(query); + int idIndex = bean.getColumnNames().indexOf(ids.get(tbIndex) ); while ((row = bean.getNextRow()) != null) { j++; @@ -440,6 +441,9 @@ class Convert else pstm.setNull(k + 1, Types.NULL); } + pstm.setString(row.size()+1,row.get(idIndex).toString()); + //System.out.println(pstm.toString()); + // System.exit(0); pstm.execute(); //stm.executeUpdate(command.toString()); if(dialog!=null) @@ -452,9 +456,12 @@ class Convert } catch (Exception e) { System.out.println("Error while connecting to database " + e); - dialog.setVisible(false); - dialog.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); - FM2SQL.fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); + if (dialog != null) + { + dialog.setVisible(false); + dialog.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); + FM2SQL.fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); + } java.io.ByteArrayOutputStream b = new java.io.ByteArrayOutputStream(); java.io.PrintStream stream = new java.io.PrintStream(b); stream.print(command + "\n\n"); @@ -462,10 +469,14 @@ class Convert FM2SQL.showErrorDialog(b.toString(), "Error occured !"); } - dialog.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); - FM2SQL.fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); + if (dialog != null) + { + dialog.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); + FM2SQL.fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); + + dialog.setVisible(false); + } - dialog.setVisible(false); } @@ -782,7 +793,15 @@ class Convert { alterMe.setCharAt(j, '_'); - } + } else if (alterMe.charAt(j) == '?') + { + // changed ? to _ because of update statement + alterMe.setCharAt(j,'_'); + // length = length + 1; + // j=j+1; + System.out.println(alterMe); + } + else if (alterMe.charAt(j) == '.') { if(j==length-1) @@ -974,7 +993,7 @@ class Convert Node node1 = root.find("convert/source/database/user", new int[] { 1, 1, i, 1, 1 }); Node node2 = root.find("convert/source/database/password", new int[] { 1, 1, i, 1, 1 }); Node node3 = root.find("convert/source/database", new int[] { 1, 1, i}); - Node nodeMode = root.find("convert/source/database/mode/", new int[] {1, 1, i, 1,1}); + Node nodeMode = root.find("convert/source/database/mode", new int[] {1, 1, i, 1,1}); if(node3== null) throw new Error("parse error database tag missing"); if(node==null) throw new Error("parse error url tag missing"); @@ -1059,8 +1078,11 @@ class Convert for (Iterator iter = databases.iterator(); iter.hasNext();) { DataBase db = (DataBase) iter.next(); + if(mode!=DataBase.UPDATE_MODE) convertBatch(db.bean,database,db.tables,db.layouts,db.selects,db.creates,mode); - + else + update(db.bean.url,database.url,db.tables,db.layouts,db.selects,db.creates,db.ids,mode); + } // printContents(node3); // FM2SQL.fmInstance=new FM2SQL(); @@ -1390,9 +1412,11 @@ public static class DataBase this.creates = creates; this.ids = ids; this.mode = mode; + this.bean.setIDVector(ids); } public void exportToXML(BufferedWriter buffr) throws Exception { + // ids=bean.getIDVector(); buffr.write(" \n"); buffr.write(" "+bean.url+"\n"); buffr.write(" "+bean.user+"\n"); @@ -1417,7 +1441,7 @@ public static class DataBase String create=(String)creates.get(index); String id=(String)ids.get(index); - buffr.write(" \n"); + buffr.write("
\n"); buffr.write(" \n"); if(!create.equals("")) buffr.write(" "+create+" \n");