--- FM2SQL/src/Convert.java 2005/09/06 10:53:16 1.14 +++ FM2SQL/src/Convert.java 2006/10/04 20:37:52 1.17 @@ -137,7 +137,7 @@ class Convert static Vector postSQLCommands = new Vector(); - static final String versionID = new String("FM2SQL Version 0.9.8b\n"); + static final String versionID = new String("FM2SQL Version 0.9.10b\n"); private static boolean noError = false; @@ -539,12 +539,22 @@ class Convert destTableName = prop.destTableName; if (mode == Convert.DataBase.CONVERT_TEMP_MODE) { + String tableNameSave=destTableName; destTableName += _TEMP; + if(creates.get(tbIndex)!="") + { + System.out.println("Changed tablename of create statement to "+destTableName); + StringBuffer buffer=new StringBuffer(creates.get(tbIndex).toString()); + int startIndex = buffer.indexOf(tableNameSave); + buffer.replace(startIndex,startIndex+tableNameSave.length(),destTableName); + creates.set(tbIndex,buffer.toString()); + } } + System.out.println("destTableName is now "+destTableName); + fieldNames = prop.fieldNames; if (mode == Convert.DataBase.CONVERT_MODE || mode == Convert.DataBase.CONVERT_TEMP_MODE) { - if (tables.indexOf(destTableName) >= 0) { stm.executeUpdate("drop table " + beanDest.getQC() + destTableName + beanDest.getQC()); @@ -588,8 +598,11 @@ class Convert command.append(" )"); } else - command = new StringBuffer().append(creates.get(tbIndex).toString().toLowerCase()); - stm.executeUpdate(command.toString()); + { + command = new StringBuffer().append(creates.get(tbIndex).toString()); + } + System.out.println("create statement: "+command.toString()); + stm.executeUpdate(command.toString()); } } @@ -826,41 +839,39 @@ class Convert throws Exception, SQLException { Vector row; - while ((row = bean.getNextRow()) != null) - { - j++; - Object obj = null; - for (int k = 0; k < row.size(); ++k) - { - obj = row.get(k); - - if (obj instanceof ArrayList) - obj = formatFileMakerArray((List) obj, delimiter); - - String str = (obj == null) ? "NULL" : obj.toString(); - if (obj instanceof Double) - { - pstm.setDouble(k + 1, ((Double) obj).doubleValue()); - } else if (!str.equals("NULL")) - pstm.setString(k + 1, str); - else - pstm.setNull(k + 1, Types.NULL); - } - pstm.execute(); - if (isGUI) - dialog.progress.setValue((int) (((double) (j + 1) / (double) rowCount) * 100.0)); - command = null; - } // to while loop + while ((row = bean.getNextRow()) != null) { + j++; + Object obj = null; + for (int k = 0; k < row.size(); ++k) { + obj = row.get(k); + + if (obj instanceof ArrayList) + obj = formatFileMakerArray((List) obj, delimiter); + + String str = (obj == null) ? "NULL" : obj.toString(); + if (obj instanceof Double) { + pstm.setDouble(k + 1, ((Double) obj).doubleValue()); + } else if (!str.equals("NULL")) + pstm.setString(k + 1, str); + else + pstm.setNull(k + 1, Types.NULL); + } + pstm.execute(); + if (isGUI) + dialog.progress + .setValue((int) (((double) (j + 1) / (double) rowCount) * 100.0)); + command = null; + } // to while loop return command; } /** - * removes special characters from the input string as well as .fp5 - * - * @param newName - * String to change - * @return - */ + * removes special characters from the input string as well as .fp5 + * + * @param newName + * String to change + * @return + */ public static String convertText(String newName) { StringBuffer alterMe = new StringBuffer(newName.trim().toLowerCase()); @@ -1274,6 +1285,7 @@ class Convert else if (modeString.equals("convert_temp")) mode = DataBase.CONVERT_TEMP_MODE; + System.out.println("mode ist "+mode); // if(node3!=null) // System.out.println(node3.name); @@ -2204,7 +2216,7 @@ class Convert // CREATE UNIQUE INDEX title_idx ON films (title); for (Iterator iter = linesToDelete.iterator(); iter.hasNext();) { - String id = (String) iter.next(); + String id = iter.next().toString(); delPSt.setString(1, id); delPSt.execute(); @@ -2252,7 +2264,7 @@ class Convert dialog.title.setText("Retrieving new data"); } - Vector[] vectors = bean.getQueryData(tempQuery, deltaID); + Vector[] vectors = bean.getQueryData(tempQuery, 0); int count = 0, size = vectors[0].size(); int idIndex = vectors[1].indexOf(idField); // System.out.println(idIndex + " " + vectors[1] + " " + idField); @@ -2295,7 +2307,8 @@ class Convert } updPst.setString(line.size() + 1, line.get(idIndex).toString()); // updPst.addBatch(); - // updPst.execute(); + // System.out.println("updating "+line.get(idIndex).toString()+" "+line); + updPst.execute(); } if (dialog != null) {