version 1.54, 2004/04/06 10:34:15
|
version 1.55, 2004/06/01 10:29:48
|
Line 78 class Convert
|
Line 78 class Convert
|
bean = source; |
bean = source; |
beanDest = destination; |
beanDest = destination; |
convert(null,null,names,layouts,selects,creates,ids,mode,delimiter); |
convert(null,null,names,layouts,selects,creates,ids,mode,delimiter); |
if(true) return; |
if (true) |
|
return; |
StringBuffer command = null; |
StringBuffer command = null; |
try |
try |
{ |
{ |
Line 462 class Convert
|
Line 463 class Convert
|
* @throws Exception |
* @throws Exception |
*/ |
*/ |
|
|
|
|
public static void convert(String source, String destination, Vector names, Vector layouts, Vector selects, Vector creates, Vector ids, int mode,String delimiter) throws Exception |
public static void convert(String source, String destination, Vector names, Vector layouts, Vector selects, Vector creates, Vector ids, int mode,String delimiter) throws Exception |
{ |
{ |
|
|
Line 483 class Convert
|
Line 483 class Convert
|
int deltaID = 1; |
int deltaID = 1; |
String idField = ""; |
String idField = ""; |
String destTableName = ""; |
String destTableName = ""; |
|
String[] fieldNames = null; |
if (source != null && destination != null) |
if (source != null && destination != null) |
{ |
{ |
// setting user and passwd |
// setting user and passwd |
Line 563 class Convert
|
Line 564 class Convert
|
String create =creates.get(tbIndex).toString().toLowerCase(); |
String create =creates.get(tbIndex).toString().toLowerCase(); |
int fromIndex = create.indexOf("table")+5; |
int fromIndex = create.indexOf("table")+5; |
int toIndex = create.indexOf("("); |
int toIndex = create.indexOf("("); |
|
int endIndex = create.indexOf(")", toIndex); |
|
|
destTableName = create.substring(fromIndex,toIndex).replaceAll(beanDest.getQC(),"").trim(); |
destTableName = create.substring(fromIndex,toIndex).replaceAll(beanDest.getQC(),"").trim(); |
System.out.println("destTable "+destTableName); |
System.out.println("destTable "+destTableName); |
|
// retrieve field_names from select statement |
|
if (query.indexOf("*") < 0) |
|
{ |
|
int selectEndIndex = query.indexOf("from"); |
|
StringTokenizer tokenizer = new StringTokenizer(query.substring(6, selectEndIndex), ","); |
|
int numFields = tokenizer.countTokens(); |
|
fieldNames = new String[numFields]; |
|
int fieldIndex = 0; |
|
while (tokenizer.hasMoreTokens()) |
|
{ |
|
String fieldName = tokenizer.nextToken().trim(); |
|
fieldNames[fieldIndex] = convertText(fieldName); |
|
System.out.println(fieldNames[fieldIndex]); |
|
fieldIndex++; |
|
} |
|
|
} else |
} else |
|
{ |
|
// use create statement for field names |
|
StringTokenizer tokenizer = new StringTokenizer(create.substring(toIndex + 1, endIndex), ","); |
|
int numFields = tokenizer.countTokens(); |
|
fieldNames = new String[numFields]; |
|
int fieldIndex = 0; |
|
while (tokenizer.hasMoreTokens()) |
|
{ |
|
String fieldName = tokenizer.nextToken().trim(); |
|
int index = fieldName.lastIndexOf(" "); |
|
fieldNames[fieldIndex] = fieldName.substring(0, index); |
|
System.out.println(fieldNames[fieldIndex]); |
|
fieldIndex++; |
|
} |
|
} |
|
} else |
|
{ |
destTableName = convertText(names.get(tbIndex).toString()); |
destTableName = convertText(names.get(tbIndex).toString()); |
|
|
|
// retrieve field_names from select statement |
|
if (query.indexOf("*") < 0) |
|
{ |
|
int selectEndIndex = query.indexOf("from"); |
|
StringTokenizer tokenizer = new StringTokenizer(query.substring(6, selectEndIndex), ","); |
|
int numFields = tokenizer.countTokens(); |
|
fieldNames = new String[numFields]; |
|
int fieldIndex = 0; |
|
while (tokenizer.hasMoreTokens()) |
|
{ |
|
String fieldName = tokenizer.nextToken().trim(); |
|
fieldNames[fieldIndex] = convertText(fieldName); |
|
// System.out.println("field "+ fieldNames[fieldIndex]); |
|
fieldIndex++; |
|
} |
|
|
|
} else |
|
{ |
|
Vector fieldNamesVec = bean.getColumnNames(); |
|
fieldNames = new String[fieldNamesVec.size()]; |
|
int fieldIndex = -1; |
|
for (Iterator iter = fieldNamesVec.iterator(); iter.hasNext();) |
|
{ |
|
String element = (String) iter.next(); |
|
fieldNames[++fieldIndex] = bean.getQC() + convertText(element) + bean.getQC(); |
|
// System.out.println("field " + fieldNames[fieldIndex]); |
|
} |
|
} |
|
} |
if (mode == Convert.DataBase.CONVERT_MODE) |
if (mode == Convert.DataBase.CONVERT_MODE) |
{ |
{ |
|
|
Line 644 class Convert
|
Line 708 class Convert
|
command.append(beanDest.getQC()); |
command.append(beanDest.getQC()); |
command.append(destTableName); //convertText((String) names.get(tbIndex))); |
command.append(destTableName); //convertText((String) names.get(tbIndex))); |
command.append(beanDest.getQC()); |
command.append(beanDest.getQC()); |
|
command.append(" ("); |
|
for (int i = 0; i < fieldNames.length; i++) |
|
{ |
|
command.append(fieldNames[i]); |
|
if (i < fieldNames.length - 1) |
|
command.append(","); |
|
} |
|
command.append(") "); |
|
|
command.append(" values ( "); |
command.append(" values ( "); |
|
|
Line 668 class Convert
|
Line 740 class Convert
|
++counter; |
++counter; |
if (counter == 0&&dialog!=null) |
if (counter == 0&&dialog!=null) |
dialog.title.setText("Check if data is available"); |
dialog.title.setText("Check if data is available"); |
else |
else if (dialog != null) |
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, numHits); |
myIds = bean.getIDVector(ids.get(tbIndex).toString(), (String) names.get(tbIndex), tempQuery, numHits); |
if (myIds.isEmpty()) |
if (myIds.isEmpty()) |
Line 832 class Convert
|
Line 903 class Convert
|
if(obj instanceof Double) |
if(obj instanceof Double) |
{ |
{ |
pstm.setDouble(k + 1, ((Double)obj).doubleValue()); |
pstm.setDouble(k + 1, ((Double)obj).doubleValue()); |
}else |
} else if (!str.equals("NULL")) |
if (!str.equals("NULL")) |
|
pstm.setString(k + 1, str); |
pstm.setString(k + 1, str); |
else |
else |
pstm.setNull(k + 1, Types.NULL); |
pstm.setNull(k + 1, Types.NULL); |
Line 1148 class Convert
|
Line 1218 class Convert
|
throw new Error("parse error user tag missing"); |
throw new Error("parse error user tag missing"); |
if (node2 == null) |
if (node2 == null) |
throw new Error("parse error password tag missing"); |
throw new Error("parse error password tag missing"); |
if(delimiterNode!=null) delimiter = delimiterNode.getCharacters(); |
if (delimiterNode != null) |
|
delimiter = delimiterNode.getCharacters(); |
String url = node.getCharacters(); |
String url = node.getCharacters(); |
String user = node1.getCharacters(); |
String user = node1.getCharacters(); |
String password = node2.getCharacters(); |
String password = node2.getCharacters(); |