version 1.10, 2005/04/19 10:49:05
|
version 1.11, 2005/04/22 10:57:32
|
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; |
|
import java.util.Locale; |
import java.util.StringTokenizer; |
import java.util.StringTokenizer; |
import java.util.TreeSet; |
import java.util.TreeSet; |
import java.util.Vector; |
import java.util.Vector; |
Line 47 import com.exploringxml.xml.Xparse;
|
Line 50 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 133 class Convert
|
Line 138 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.2b\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.SHORT); |
|
d.setTimeZone(java.util.TimeZone.getTimeZone("CET")); |
|
|
|
String date = d.format(new Date()); |
|
date = date.replace(':', '_'); |
|
renameTable(beanDest, addQuotes(beanDest, originalName), addQuotes(beanDest, |
|
convertText(originalName + "_" + date))); |
|
} |
|
renameTable(beanDest, addQuotes(beanDest, destTableName), addQuotes(beanDest, |
|
originalName)); |
|
} |
} |
} |
} catch (Exception e) |
} catch (Exception e) |
{ |
{ |
Line 728 class Convert
|
Line 753 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 762 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 1144 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) |
{ |
{ |
|
|