|
|
| version 1.10, 2005/04/19 10:49:05 | version 1.13, 2005/05/02 12:45:36 |
|---|---|
| Line 29 import java.sql.ResultSet; | Line 29 import java.sql.ResultSet; |
| import java.sql.SQLException; | import java.sql.SQLException; |
| import java.sql.Statement; | import java.sql.Statement; |
| import java.sql.Types; | import java.sql.Types; |
| import java.text.DateFormat; | |
| import java.text.ParseException; | import java.text.ParseException; |
| import java.util.ArrayList; | import java.util.ArrayList; |
| import java.util.Date; | |
| import java.util.Hashtable; | import java.util.Hashtable; |
| import java.util.Iterator; | import java.util.Iterator; |
| import java.util.List; | import java.util.List; |
| Line 47 import com.exploringxml.xml.Xparse; | Line 49 import com.exploringxml.xml.Xparse; |
| class Convert | class Convert |
| { | { |
| private static final String _TEMP = "_temp"; | |
| /** | /** |
| * Helper class for index creation | * Helper class for index creation |
| * | * |
| Line 119 class Convert | Line 123 class Convert |
| final static int numIntervalls = 4; | final static int numIntervalls = 4; |
| static boolean debug = !false; | static boolean debug = false; |
| static boolean isGUI = true; | static boolean isGUI = true; |
| Line 133 class Convert | Line 137 class Convert |
| static Vector postSQLCommands = new Vector(); | static Vector postSQLCommands = new Vector(); |
| static final String versionID = new String("FM2SQL Version 0.9.1b\n"); | static final String versionID = new String("FM2SQL Version 0.9.6b\n"); |
| private static boolean noError = false; | private static boolean noError = false; |
| public static void main(String args[]) throws IOException | public static void main(String args[]) throws IOException |
| { | { |
| // DateFormat d = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, | |
| // Locale.GERMANY); | |
| // System.out.println(convertText("rogoistSuper" + "_" + d.format(new Date()).replace(':', '_'))); | |
| /* | /* |
| * try { //byte[] b = "�".getBytes("UTF-8"); // | * try { //byte[] b = "�".getBytes("UTF-8"); // |
| * System.out.println("QueryString " +b[0]+" "+b[1]+(new | * System.out.println("QueryString " +b[0]+" "+b[1]+(new |
| Line 531 class Convert | Line 539 class Convert |
| destTableName = prop.destTableName; | destTableName = prop.destTableName; |
| if (mode == Convert.DataBase.CONVERT_TEMP_MODE) | if (mode == Convert.DataBase.CONVERT_TEMP_MODE) |
| { | { |
| destTableName += "_temp"; | destTableName += _TEMP; |
| } | } |
| fieldNames = prop.fieldNames; | fieldNames = prop.fieldNames; |
| if (mode == Convert.DataBase.CONVERT_MODE || mode == Convert.DataBase.CONVERT_TEMP_MODE) | if (mode == Convert.DataBase.CONVERT_MODE || mode == Convert.DataBase.CONVERT_TEMP_MODE) |
| Line 712 class Convert | Line 720 class Convert |
| if (isGUI) | if (isGUI) |
| resetGUI(dialog); | resetGUI(dialog); |
| noError = true; | noError = true; |
| if (mode == Convert.DataBase.CONVERT_TEMP_MODE) | |
| { | |
| String originalName = destTableName.split(_TEMP)[0]; | |
| // TODO | |
| if (beanDest.getTableNames().contains(originalName)) | |
| { | |
| DateFormat d = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM); | |
| d.setTimeZone(java.util.TimeZone.getTimeZone("CET")); | |
| String date = d.format(new Date()); | |
| date = date.replace(':', '_'); | |
| String newName = addQuotes(beanDest, convertText(originalName + "_" + date)); | |
| // rename table to newName | |
| renameTable(beanDest, addQuotes(beanDest, originalName), newName); | |
| } | |
| // rename Table_temp to originalName | |
| renameTable(beanDest, addQuotes(beanDest, destTableName), addQuotes(beanDest, | |
| originalName)); | |
| } | |
| } | } |
| } catch (Exception e) | } catch (Exception e) |
| { | { |
| Line 728 class Convert | Line 755 class Convert |
| } | } |
| } catch (Error e) | } catch (Error e) |
| { | { |
| noError = false; | |
| System.out.println(e); | System.out.println(e); |
| e.printStackTrace(); | e.printStackTrace(); |
| } | } |
| Line 735 class Convert | Line 764 class Convert |
| } | } |
| /** | /** |
| * | |
| * @param beanDest2 | |
| * @param originalName | |
| * @return | |
| */ | |
| private static String addQuotes(DBBean bean, String originalName) | |
| { | |
| return bean.getQC() + originalName + bean.getQC(); | |
| } | |
| /** | |
| * @param names | * @param names |
| * @param dialog | * @param dialog |
| * @param tbIndex | * @param tbIndex |
| Line 1106 class Convert | Line 1146 class Convert |
| } | } |
| } | } |
| /** | |
| * | |
| * @param database | |
| * @param db | |
| * @throws Exception | |
| * @throws SQLException | |
| */ | |
| private static void renameTable(DBBean database, String sourceTable, String destTable) | |
| throws SQLException, Exception | |
| { | |
| String command = "alter table " + sourceTable + " rename " + " to " + destTable; | |
| SQLCommand sqlCommand = new SQLCommand(database, command); | |
| sqlCommand.executeCommand(); | |
| } | |
| public static Vector getXMLConfig(StringBuffer sb) | public static Vector getXMLConfig(StringBuffer sb) |
| { | { |
| Line 1545 class Convert | Line 1600 class Convert |
| buffr.write(" <password>" + bean.passwd + "</password>\n"); | buffr.write(" <password>" + bean.passwd + "</password>\n"); |
| buffr.write(" <delimiter>" + delimiter + "</delimiter>\n"); | buffr.write(" <delimiter>" + delimiter + "</delimiter>\n"); |
| String modeString = ""; | String modeString = ""; |
| if (mode == CONVERT_MODE) | if (mode == CONVERT_TEMP_MODE) |
| modeString = "convert_temp"; | |
| else if (mode == CONVERT_MODE) | |
| modeString = "convert"; | modeString = "convert"; |
| else if (mode == APPEND_MODE) | else if (mode == APPEND_MODE) |
| modeString = "append"; | modeString = "append"; |