version 1.73, 2004/08/16 09:45:58
|
version 1.77, 2004/09/20 11:57:41
|
Line 26 import java.io.PrintStream;
|
Line 26 import java.io.PrintStream;
|
import java.io.UnsupportedEncodingException; |
import java.io.UnsupportedEncodingException; |
import java.net.URL; |
import java.net.URL; |
import java.sql.PreparedStatement; |
import java.sql.PreparedStatement; |
|
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; |
Line 38 import java.util.StringTokenizer;
|
Line 39 import java.util.StringTokenizer;
|
import java.util.TreeSet; |
import java.util.TreeSet; |
import java.util.Vector; |
import java.util.Vector; |
|
|
|
import javax.swing.JDialog; |
|
import javax.swing.JLabel; |
|
import javax.swing.JPanel; |
|
|
import com.exploringxml.xml.Node; |
import com.exploringxml.xml.Node; |
import com.exploringxml.xml.Xparse; |
import com.exploringxml.xml.Xparse; |
|
|
Line 76 class Convert
|
Line 81 class Convert
|
static boolean batchRun = false; |
static boolean batchRun = false; |
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 = 4; |
static boolean debug = false; |
static boolean debug = false; |
public static void main(String args[]) |
public static void main(String args[]) |
{ |
{ |
Line 2061 class Convert
|
Line 2066 class Convert
|
int endIndex = -1; |
int endIndex = -1; |
String tempQuery = query; |
String tempQuery = query; |
String destQuery = query.replaceAll(names.get(tbIndex).toString(), destTableName); |
String destQuery = query.replaceAll(names.get(tbIndex).toString(), destTableName); |
|
destQuery = destQuery.replaceAll(bean.getQC(), beanDest.getQC()); |
|
destQuery = removeLayoutPartFromQuery(destQuery, layouts.get(tbIndex).toString()); |
|
// TODO remove layout part for destQuery |
String tempQueryDest = destQuery; |
String tempQueryDest = destQuery; |
// remove extra query parts destQuery.substring(0,destQuery.lastIndexOf(destTableName)+destTableName.length()+1); |
// remove extra query parts destQuery.substring(0,destQuery.lastIndexOf(destTableName)+destTableName.length()+1); |
System.out.println("new Query " + tempQueryDest); |
System.out.println("new Query " + tempQueryDest); |
|
System.out.println("idfield "+idField+" "+ids.get(tbIndex).toString()); |
if (!idField.equals("")) |
if (!idField.equals("")) |
{ |
{ |
long startTime = System.currentTimeMillis(); |
long startTime = System.currentTimeMillis(); |
Line 2077 class Convert
|
Line 2086 class Convert
|
dialog.title.setText("Check if data is available"); |
dialog.title.setText("Check if data is available"); |
else if (dialog != null) |
else if (dialog != null) |
dialog.title.setText("Check if more data is available"); |
dialog.title.setText("Check if more data is available"); |
|
|
myIds = bean.getIDVector(ids.get(tbIndex).toString(), (String) names.get(tbIndex), tempQuery, 0); |
myIds = bean.getIDVector(ids.get(tbIndex).toString(), (String) names.get(tbIndex), tempQuery, 0); |
myIdsDest = beanDest.getIDVector(convertText(idField), destTableName, tempQueryDest, 0); |
myIdsDest = beanDest.getIDVector(convertText(idField), destTableName, tempQueryDest, 0); |
//System.out.println("status of remove "+myIds.remove("b015892")); |
//System.out.println("status of remove "+myIds.remove("b015892")); |
|
System.out.println("ids found for "+idField+" "+!myIds.isEmpty()); |
if (myIds.isEmpty()) |
if (myIds.isEmpty()) |
break; |
break; |
vec = new Vector(myIds); |
vec = new Vector(myIds); |
Line 2167 class Convert
|
Line 2178 class Convert
|
System.out.println("found list " + idList); |
System.out.println("found list " + idList); |
Statement stm = beanDest.getConnection().createStatement(); |
Statement stm = beanDest.getConnection().createStatement(); |
Vector destTables = beanDest.getTableNames(); |
Vector destTables = beanDest.getTableNames(); |
|
System.out.println("tempQueryDest" + tempQueryDest); |
beanDest.makeQuery(tempQueryDest,0); |
beanDest.makeQuery(tempQueryDest,0); |
for (Iterator iter = idList.iterator(); iter.hasNext();) |
for (Iterator iter = idList.iterator(); iter.hasNext();) |
{ |
{ |
Line 2178 class Convert
|
Line 2190 class Convert
|
stm.execute("DROP INDEX "+destTableName+"_"+indexField); |
stm.execute("DROP INDEX "+destTableName+"_"+indexField); |
// continue; |
// continue; |
} |
} |
|
// stm.execute("DROP INDEX "+destTableName+"_"+indexField); |
|
|
String type = beanDest.getColumnType(indexField).toLowerCase(); |
String type = beanDest.getColumnType(indexField).toLowerCase(); |
// System.out.println(indexField+" "+type+" "+(type.indexOf("text") >= 0 || type.indexOf("varchar") >= 0 || type.indexOf("char") >= 0)); |
// 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) |
if (type.indexOf("text") >= 0 || type.indexOf("varchar") >= 0 || type.indexOf("char") >= 0) |
stm.execute("CREATE INDEX " + indexName + " ON " + destTableName + "(LOWER(" + indexField + "))"); |
{ |
else |
if (beanDest.url.indexOf("mysql") >= 0) |
|
{ |
|
//System.out.println("CREATE INDEX " + indexName + " ON " + destTableName + " (" + indexField + "(10))"); |
|
// TODO problem if index exist !!! |
|
stm.execute("CREATE INDEX " + indexName + " ON " + destTableName + " (" + indexField + "(10))"); |
|
} else |
|
{ |
|
stm.execute("CREATE INDEX " + indexName + " ON " + destTableName + " (lower( " + indexField + "))"); |
|
|
|
} |
|
|
|
} else |
|
{ |
stm.execute("CREATE INDEX " + destTableName + "_" + indexField + " ON " + destTableName + "(" + indexField + ")"); |
stm.execute("CREATE INDEX " + destTableName + "_" + indexField + " ON " + destTableName + "(" + indexField + ")"); |
|
|
|
} |
|
|
// stm.execute("DROP INDEX "+destTableName+"_"+indexField); |
// stm.execute("DROP INDEX "+destTableName+"_"+indexField); |
|
|
} |
} |
Line 2228 class Convert
|
Line 2255 class Convert
|
dialog.setVisible(false); |
dialog.setVisible(false); |
} |
} |
} |
} |
|
/** |
|
* @param destQuery |
|
* @param string |
|
* @return |
|
*/ |
|
private static String removeLayoutPartFromQuery(String destQuery, String layoutName) |
|
{ |
|
String removeString = "layout " + beanDest.getQC() + layoutName + beanDest.getQC(); |
|
destQuery = destQuery.replaceFirst(removeString, ""); |
|
System.out.println("destQuery change to " + destQuery); |
|
return destQuery; |
|
} |
private static void performSynchronize( |
private static void performSynchronize( |
String idField, |
String idField, |
Vector vec, |
Vector vec, |
Line 3883 class Convert
|
Line 3922 class Convert
|
command.append("WHERE " + idField + " = ?"); |
command.append("WHERE " + idField + " = ?"); |
return command; |
return command; |
} |
} |
|
public void makeTest(String table,String idField,String tempQuery) throws Exception |
|
{ |
|
int counter=0; |
|
|
|
// ****** test code ***** |
|
|
|
bean.getConnection(); |
|
ResultSet resultSet=null; |
|
String lastResult ="P227634.11";//"P227625.79554";//"P227625.77391";//"P116034.970998"; |
|
String myQuery="select "+bean.getQC()+idField+bean.getQC()+",serial "+" from "+bean.getQC()+table+bean.getQC(); |
|
System.out.println("Query is now "+myQuery); |
|
JDialog statusDialog=new JDialog(); |
|
statusDialog.setTitle("Status Information"); |
|
JLabel status=new JLabel("actual DataSet : "); |
|
JLabel status2=new JLabel(Integer.toString(++counter)); |
|
JLabel status3=new JLabel(lastResult); |
|
|
|
JPanel statusPanel = new JPanel(); |
|
JPanel statusPanel2 = new JPanel(); |
|
statusPanel.add(status); |
|
statusPanel.add(status2); |
|
statusPanel2.add(status3); |
|
statusDialog.getContentPane().add(statusPanel,"North"); |
|
statusDialog.getContentPane().add(statusPanel2,"Center"); |
|
statusDialog.setLocation(400,500); |
|
statusDialog.setSize(300,150); |
|
statusDialog.setVisible(true); |
|
while (true) |
|
{ |
|
if (!statusDialog.isVisible()) |
|
statusDialog.setVisible(true); |
|
tempQuery = myQuery + " where " + bean.getQC() + idField + bean.getQC() + ">'" + lastResult + "'"; |
|
resultSet = bean.makeQuery(tempQuery, 1); |
|
if (resultSet == null) |
|
{ |
|
System.out.println("lastResult was " + lastResult + " counter was " + counter); |
|
break; |
|
} else |
|
{ |
|
resultSet.next(); |
|
lastResult = resultSet.getString(1); |
|
counter++; |
|
status2.setText(Integer.toString(counter)); |
|
status3.setText(lastResult+" "+resultSet.getString(2)); |
|
if(counter%100==0) |
|
{ |
|
System.out.println("actual Result was " + lastResult + " counter was " + counter); |
|
// break; |
|
} |
|
} |
|
resultSet = null; |
|
} |
|
System.exit(0); |
|
|
|
//****** end Test ****** |
|
|
|
} |
} |
} |
|
|