version 1.70, 2004/08/08 12:01:41
|
version 1.73, 2004/08/16 09:45:58
|
Line 41 import java.util.Vector;
|
Line 41 import java.util.Vector;
|
import com.exploringxml.xml.Node; |
import com.exploringxml.xml.Node; |
import com.exploringxml.xml.Xparse; |
import com.exploringxml.xml.Xparse; |
|
|
|
|
class Convert |
class Convert |
{ |
{ |
/**Helper class for index creation |
/**Helper class for index creation |
Line 78 class Convert
|
Line 77 class Convert
|
static Vector databases = new Vector(); |
static Vector databases = new Vector(); |
final static int numHits = 5000; |
final static int numHits = 5000; |
final static int numIntervalls = 2; |
final static int numIntervalls = 2; |
|
static boolean debug = false; |
public static void main(String args[]) |
public static void main(String args[]) |
{ |
{ |
/* try |
/* try |
Line 102 class Convert
|
Line 102 class Convert
|
{ |
{ |
e1.printStackTrace(); |
e1.printStackTrace(); |
} |
} |
PrintStream stream = new PrintStream(file); |
PrintStream stream = new PrintStream(file,false); |
// System.setOut(stream); |
if(!debug) |
//System.setErr(stream); |
{ |
|
System.setOut(stream); |
|
System.setErr(stream); |
|
} |
readXMLFile(args[0]); |
readXMLFile(args[0]); |
if (!(new File(args[0]).exists())) |
if (!(new File(args[0]).exists())) |
System.exit(0); |
System.exit(0); |
Line 1308 class Convert
|
Line 1310 class Convert
|
userDest = database.user; |
userDest = database.user; |
passwdDest = database.passwd; |
passwdDest = database.passwd; |
|
|
synchronize(db.bean.url, database.url, db.tables, db.layouts, db.selects, db.creates, db.ids, mode, db.delimiter); |
synchronize(db.bean.url, database.url, db.tables, db.layouts, db.selects, db.creates, db.ids, mode, db.delimiter, new Vector(db.htIndex.values())); |
} |
} |
} |
} |
// printContents(node3); |
// printContents(node3); |
Line 1961 class Convert
|
Line 1963 class Convert
|
*/ |
*/ |
// TODO implement append,update and delete in one method |
// TODO implement append,update and delete in one method |
// TODO using id based algorithm |
// TODO using id based algorithm |
public static void synchronize(String source, String destination, Vector names, Vector layouts, Vector selects, Vector creates, Vector ids, int mode, String delimiter) throws Exception |
public static void synchronize(String source, String destination, Vector names, Vector layouts, Vector selects, Vector creates, Vector ids, int mode, String delimiter, Vector indexList) |
|
throws Exception |
{ |
{ |
System.out.println(" bin in synchronize!!!"); |
System.out.println(" bin in synchronize!!!"); |
FM2SQL.ProgressDialog dialog = null; |
FM2SQL.ProgressDialog dialog = null; |
Line 2159 class Convert
|
Line 2162 class Convert
|
tempQuery = query + " where " + tempID + ">'" + vec.lastElement() + "'"; |
tempQuery = query + " where " + tempID + ">'" + vec.lastElement() + "'"; |
|
|
} |
} |
|
String tableName = names.get(tbIndex).toString(); |
|
IndexList idList = (IndexList) indexList.get(0); |
|
System.out.println("found list " + idList); |
|
Statement stm = beanDest.getConnection().createStatement(); |
|
Vector destTables = beanDest.getTableNames(); |
|
beanDest.makeQuery(tempQueryDest,0); |
|
for (Iterator iter = idList.iterator(); iter.hasNext();) |
|
{ |
|
String indexField = (String) iter.next(); |
|
indexField = convertText(indexField); |
|
String indexName = destTableName + "_" + indexField; |
|
if (destTables.contains(indexName)) |
|
{ |
|
stm.execute("DROP INDEX "+destTableName+"_"+indexField); |
|
// continue; |
|
} |
|
|
|
String type = beanDest.getColumnType(indexField).toLowerCase(); |
|
// System.out.println(indexField+" "+type+" "+(type.indexOf("text") >= 0 || type.indexOf("varchar") >= 0 || type.indexOf("char") >= 0)); |
|
if (type.indexOf("text") >= 0 || type.indexOf("varchar") >= 0 || type.indexOf("char") >= 0) |
|
stm.execute("CREATE INDEX " + indexName + " ON " + destTableName + "(LOWER(" + indexField + "))"); |
|
else |
|
stm.execute("CREATE INDEX " + destTableName + "_" + indexField + " ON " + destTableName + "(" + indexField + ")"); |
|
|
|
// stm.execute("DROP INDEX "+destTableName+"_"+indexField); |
|
|
|
} |
|
// CREATE UNIQUE INDEX title_idx ON films (title); |
for (Iterator iter = linesToDelete.iterator(); iter.hasNext();) |
for (Iterator iter = linesToDelete.iterator(); iter.hasNext();) |
{ |
{ |
String id = (String) iter.next(); |
String id = (String) iter.next(); |
Line 2247 class Convert
|
Line 2277 class Convert
|
updPst.setNull(l + 1, Types.NULL); |
updPst.setNull(l + 1, Types.NULL); |
} |
} |
updPst.setString(line.size() + 1, line.get(idIndex).toString()); |
updPst.setString(line.size() + 1, line.get(idIndex).toString()); |
|
//updPst.addBatch(); |
updPst.execute(); |
updPst.execute(); |
|
|
} |
} |
} |
} |
|
//updPst.executeBatch(); |
} // to method |
} // to method |
|
|
/** |
/** |