version 1.82, 2004/10/19 11:57:26
|
version 1.83, 2004/10/26 08:37:10
|
Line 18 import java.io.File;
|
Line 18 import java.io.File;
|
import java.io.FileInputStream; |
import java.io.FileInputStream; |
import java.io.FileNotFoundException; |
import java.io.FileNotFoundException; |
import java.io.FileOutputStream; |
import java.io.FileOutputStream; |
|
import java.io.IOException; |
import java.io.InputStream; |
import java.io.InputStream; |
import java.io.InputStreamReader; |
import java.io.InputStreamReader; |
import java.io.OutputStreamWriter; |
import java.io.OutputStreamWriter; |
Line 94 class Convert
|
Line 95 class Convert
|
|
|
static boolean debug = false; |
static boolean debug = false; |
|
|
public static void main(String args[]) |
static boolean isGUI = true; |
|
public static void main(String args[]) throws IOException |
{ |
{ |
/* |
/* |
* try { //byte[] b = "ö".getBytes("UTF-8"); // |
* try { //byte[] b = "ö".getBytes("UTF-8"); // |
Line 103 class Convert
|
Line 105 class Convert
|
* //System.out.println(new String(b,"UTF-8")); } catch |
* //System.out.println(new String(b,"UTF-8")); } catch |
* (UnsupportedEncodingException e) { e.printStackTrace(); } |
* (UnsupportedEncodingException e) { e.printStackTrace(); } |
*/ |
*/ |
|
isGUI = false; |
FileOutputStream file = null; |
FileOutputStream file = null; |
if (args.length != 1) |
if (args.length != 1) |
{ |
{ |
Line 110 class Convert
|
Line 113 class Convert
|
System.exit(-1); |
System.exit(-1); |
} |
} |
try |
try |
{ |
{ File temp=File.createTempFile("fm2sql",".txt"); |
file = new FileOutputStream("./log.txt"); |
file = new FileOutputStream(temp); |
} |
} |
catch (FileNotFoundException e1) |
catch (FileNotFoundException e1) |
{ |
{ |
e1.printStackTrace(); |
e1.printStackTrace(); |
} |
} |
PrintStream stream = new PrintStream(file, false); |
PrintStream stream = new PrintStream(file, true); |
if (!debug) |
if (!debug) |
{ |
{ |
System.setOut(stream); |
System.setOut(stream); |
Line 329 class Convert
|
Line 332 class Convert
|
{ |
{ |
|
|
FM2SQL.ProgressDialog dialog = null; |
FM2SQL.ProgressDialog dialog = null; |
if (FM2SQL.fmInstance != null) |
if (isGUI) |
{ |
{ |
dialog = new FM2SQL.ProgressDialog(FM2SQL.fmInstance, bean); |
dialog = new FM2SQL.ProgressDialog(FM2SQL.fmInstance, bean); |
dialog.setTitle("Conversion running ..."); |
dialog.setTitle("Conversion running ..."); |
Line 351 class Convert
|
Line 354 class Convert
|
{ |
{ |
//bean.setConnection("jdbc:fmpro:http://141.14.237.74:8050"); |
//bean.setConnection("jdbc:fmpro:http://141.14.237.74:8050"); |
//bean.setConnection("jdbc:postgresql://erebos/test","postgres","rogo"); |
//bean.setConnection("jdbc:postgresql://erebos/test","postgres","rogo"); |
|
System.out.println("before getConnection"); |
|
|
bean.setConnection(source); |
bean.setConnection(source); |
|
System.out.println("after getConnection"); |
|
|
if (names == null) |
if (names == null) |
names = bean.getTableNames(); |
names = bean.getTableNames(); |
// Collections.sort(names); |
// Collections.sort(names); |
int tbIndex = 1; |
int tbIndex = 1; |
|
|
// System.out.println("Start at |
System.out.println("Start at table "+names.firstElement()); |
// "+names.indexOf("archimedes_facsimiles")); |
|
for (tbIndex = 0; tbIndex < names.size(); ++tbIndex) |
for (tbIndex = 0; tbIndex < names.size(); ++tbIndex) |
{ |
{ |
Vector[] result = null; |
Vector[] result = null; |
Line 423 class Convert
|
Line 429 class Convert
|
|
|
if (dialog != null) |
if (dialog != null) |
dialog.title.setText("Updating table data ..."); |
dialog.title.setText("Updating table data ..."); |
|
else System.out.println("Updating table data ..."); |
int j = -1; |
int j = -1; |
|
|
Vector row = null; |
Vector row = null; |
Line 510 class Convert
|
Line 516 class Convert
|
java.io.PrintStream stream = new java.io.PrintStream(b); |
java.io.PrintStream stream = new java.io.PrintStream(b); |
stream.print(command + "\n\n"); |
stream.print(command + "\n\n"); |
e.printStackTrace(stream); |
e.printStackTrace(stream); |
|
if(dialog!=null) |
FM2SQL.showErrorDialog(b.toString(), "Error occured !"); |
FM2SQL.showErrorDialog(b.toString(), "Error occured !"); |
|
|
} |
} |
Line 544 class Convert
|
Line 551 class Convert
|
|
|
FM2SQL.ProgressDialog dialog = null; |
FM2SQL.ProgressDialog dialog = null; |
|
|
if (FM2SQL.fmInstance != null) |
if (isGUI) |
{ |
{ |
dialog = new FM2SQL.ProgressDialog(FM2SQL.fmInstance, bean); |
dialog = new FM2SQL.ProgressDialog(FM2SQL.fmInstance, bean); |
dialog.setTitle("Conversion running ..."); |
dialog.setTitle("Conversion running ..."); |
Line 555 class Convert
|
Line 562 class Convert
|
dialog.thread = Thread.currentThread(); |
dialog.thread = Thread.currentThread(); |
dialog.setSize(400, 250); |
dialog.setSize(400, 250); |
} |
} |
|
|
|
System.out.println("connection established "+source+" "+bean.url); |
|
|
java.util.TreeSet myIds = new TreeSet(); |
java.util.TreeSet myIds = new TreeSet(); |
int deltaID = 1; |
int deltaID = 1; |
String idField = ""; |
String idField = ""; |
String destTableName = ""; |
String destTableName = ""; |
String[] fieldNames = null; |
String[] fieldNames = null; |
|
|
if (source != null && destination != null) |
if (source != null && destination != null) |
{ |
{ |
// setting user and passwd |
// setting user and passwd |
Line 567 class Convert
|
Line 578 class Convert
|
// setting user and passwd |
// setting user and passwd |
beanDest.setUserAndPasswd(userDest, passwdDest); |
beanDest.setUserAndPasswd(userDest, passwdDest); |
} |
} |
|
|
StringBuffer command = null; |
StringBuffer command = null; |
String query = null; |
String query = null; |
try |
try |
{ |
{ |
|
|
if (source != null) |
if (source != null) |
bean.setConnection(source); |
bean.setConnection(source); |
else |
else |
bean.setConnection(bean.url); |
bean.setConnection(bean.url); |
|
|
if (names == null) |
if (names == null) |
names = bean.getTableNames(); |
names = bean.getTableNames(); |
// Collections.sort(names); |
// Collections.sort(names); |
Line 1313 class Convert
|
Line 1325 class Convert
|
String url = node.getCharacters(); |
String url = node.getCharacters(); |
String user = node1.getCharacters(); |
String user = node1.getCharacters(); |
String password = node2.getCharacters(); |
String password = node2.getCharacters(); |
System.out.println(url); |
System.out.println(" The url is "+url); |
database.setURL(url.trim()); |
database.setURL(url.trim()); |
database.setUserAndPasswd(user.trim(), password.trim()); |
database.setUserAndPasswd(user.trim(), password.trim()); |
|
System.out.println("huhu"); |
//databases.add(database); |
//databases.add(database); |
for (Iterator iter = databases.iterator(); iter.hasNext();) |
for (Iterator iter = databases.iterator(); iter.hasNext();) |
{ |
{ |
|
System.out.println("huhu argghhhh"+(mode == DataBase.CONVERT_MODE)+" mode is "+mode); |
|
|
DataBase db = (DataBase) iter.next(); |
DataBase db = (DataBase) iter.next(); |
if (mode == DataBase.CONVERT_MODE || mode == DataBase.APPEND_MODE) |
if (mode == DataBase.CONVERT_MODE || mode == DataBase.APPEND_MODE) |
convertBatch(db.bean, database, db.tables, db.layouts, db.selects, db.creates, db.ids, mode, db.delimiter); |
convertBatch(db.bean, database, db.tables, db.layouts, db.selects, db.creates, db.ids, mode, db.delimiter); |
else if (mode == DataBase.UPDATE_MODE) |
else if (mode == DataBase.UPDATE_MODE) |
{ |
{ |
|
System.out.println("huhu arghhh arghhh arghhh"); |
|
|
Convert.user = db.bean.user; |
Convert.user = db.bean.user; |
Convert.passwd = db.bean.passwd; |
Convert.passwd = db.bean.passwd; |
userDest = database.user; |
userDest = database.user; |
Line 1831 class Convert
|
Line 1848 class Convert
|
public static void delete(String source, String destination, Vector names, Vector layouts, Vector selects, Vector creates, Vector ids, int mode) throws Exception |
public static void delete(String source, String destination, Vector names, Vector layouts, Vector selects, Vector creates, Vector ids, int mode) throws Exception |
{ |
{ |
FM2SQL.ProgressDialog dialog = null; |
FM2SQL.ProgressDialog dialog = null; |
if (FM2SQL.fmInstance != null) |
if (isGUI) |
{ |
{ |
dialog = new FM2SQL.ProgressDialog(FM2SQL.fmInstance, bean); |
dialog = new FM2SQL.ProgressDialog(FM2SQL.fmInstance, bean); |
dialog.setTitle("Conversion running ..."); |
dialog.setTitle("Conversion running ..."); |
Line 2061 class Convert
|
Line 2078 class Convert
|
{ |
{ |
System.out.println(" bin in synchronize!!!"); |
System.out.println(" bin in synchronize!!!"); |
FM2SQL.ProgressDialog dialog = null; |
FM2SQL.ProgressDialog dialog = null; |
if (FM2SQL.fmInstance != null) |
if (isGUI) |
{ |
{ |
dialog = new FM2SQL.ProgressDialog(FM2SQL.fmInstance, bean); |
dialog = new FM2SQL.ProgressDialog(FM2SQL.fmInstance, bean); |
dialog.setTitle("Synchronize running ..."); |
dialog.setTitle("Synchronize running ..."); |
Line 2355 class Convert
|
Line 2372 class Convert
|
java.io.PrintStream stream = new java.io.PrintStream(b); |
java.io.PrintStream stream = new java.io.PrintStream(b); |
stream.print(command + "\n\n"); |
stream.print(command + "\n\n"); |
e.printStackTrace(stream); |
e.printStackTrace(stream); |
|
if(dialog != null) |
FM2SQL.showErrorDialog(b.toString(), "Error occured !"); |
FM2SQL.showErrorDialog(b.toString(), "Error occured !"); |
|
|
} |
} |