Annotation of FM2SQL/Convert.java, revision 1.83
1.51 rogo 1: /*
1.79 rogo 2: * Convert.java -- Converter class - Filemaker to SQL Converter Copyright (C)
3: * 2003 Robert Gordesch (rogo@mpiwg-berlin.mpg.de) This program is free
4: * software; you can redistribute it and/or modify it under the terms of the GNU
5: * General Public License as published by the Free Software Foundation; either
6: * version 2 of the License, or (at your option) any later version. Please read
7: * license.txt for the full details. A copy of the GPL may be found at
8: * http://www.gnu.org/copyleft/lgpl.html You should have received a copy of the
9: * GNU General Public License along with this program; if not, write to the Free
10: * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
11: * USA Created on 15.09.2003 by rogo
1.51 rogo 12: */
13:
1.1 rogo 14: import java.awt.Cursor;
15: import java.io.BufferedReader;
16: import java.io.BufferedWriter;
17: import java.io.File;
18: import java.io.FileInputStream;
19: import java.io.FileNotFoundException;
20: import java.io.FileOutputStream;
1.83 ! rogo 21: import java.io.IOException;
1.60 rogo 22: import java.io.InputStream;
1.1 rogo 23: import java.io.InputStreamReader;
24: import java.io.OutputStreamWriter;
25: import java.io.PrintStream;
26: import java.io.UnsupportedEncodingException;
1.60 rogo 27: import java.net.URL;
1.57 rogo 28: import java.sql.PreparedStatement;
1.77 rogo 29: import java.sql.ResultSet;
1.57 rogo 30: import java.sql.SQLException;
31: import java.sql.Statement;
32: import java.sql.Types;
1.66 rogo 33: import java.text.ParseException;
1.57 rogo 34: import java.util.ArrayList;
1.69 rogo 35: import java.util.Hashtable;
1.57 rogo 36: import java.util.Iterator;
37: import java.util.List;
38: import java.util.StringTokenizer;
39: import java.util.TreeSet;
40: import java.util.Vector;
1.1 rogo 41:
1.77 rogo 42: import javax.swing.JDialog;
43: import javax.swing.JLabel;
44: import javax.swing.JPanel;
45:
1.1 rogo 46: import com.exploringxml.xml.Node;
47: import com.exploringxml.xml.Xparse;
48:
1.34 rogo 49: class Convert
1.1 rogo 50: {
1.79 rogo 51: /**
52: * Helper class for index creation
53: *
54: * @author rogo
55: *
56: */
57: public static class IndexList extends Vector
58: {
59: public String toString()
60: {
61: StringBuffer buff = new StringBuffer(1000);
62: int count = 0;
63: for (Iterator iter = this.iterator(); iter.hasNext();)
64: {
65: String element = (String) iter.next();
66: if (count < elementCount - 1)
67: {
68: buff.append(element).append(", ");
69: count++;
70: }
71: else
72: buff.append(element);
73:
74: }
75:
76: return buff.toString();
77: }
78: }
79:
80: static DBBean bean = new DBBean();
81:
82: static DBBean beanDest = new DBBean();
83:
84: static String user = "", passwd = "e1nste1n";
85:
86: static String userDest = "postgres", passwdDest = "rogo";
87:
88: static boolean batchRun = false;
89:
90: static Vector databases = new Vector();
91:
92: final static int numHits = 5000;
93:
94: final static int numIntervalls = 4;
95:
1.80 rogo 96: static boolean debug = false;
1.83 ! rogo 97:
! 98: static boolean isGUI = true;
! 99: public static void main(String args[]) throws IOException
1.79 rogo 100: {
101: /*
102: * try { //byte[] b = "ö".getBytes("UTF-8"); //
103: * System.out.println("QueryString " +b[0]+" "+b[1]+(new
104: * String(b).getBytes()[0])+" "+new String(b).getBytes()[1]);
105: * //System.out.println(new String(b,"UTF-8")); } catch
106: * (UnsupportedEncodingException e) { e.printStackTrace(); }
107: */
1.83 ! rogo 108: isGUI = false;
1.79 rogo 109: FileOutputStream file = null;
110: if (args.length != 1)
111: {
112: System.out.println("Usage: java Convert <xml config file>");
113: System.exit(-1);
114: }
115: try
1.83 ! rogo 116: { File temp=File.createTempFile("fm2sql",".txt");
! 117: file = new FileOutputStream(temp);
1.79 rogo 118: }
119: catch (FileNotFoundException e1)
120: {
121: e1.printStackTrace();
122: }
1.83 ! rogo 123: PrintStream stream = new PrintStream(file, true);
1.79 rogo 124: if (!debug)
125: {
126: System.setOut(stream);
127: System.setErr(stream);
128: }
129: readXMLFile(args[0]);
130: if (!(new File(args[0]).exists()))
131: System.exit(0);
132:
133: System.out.println("Finished!");
134: //convert("jdbc:fmpro:http://141.14.237.74:8050","jdbc:postgresql://erebos/test",null,null);
135: }
136:
137: public static void convertBatch(DBBean source, DBBean destination, Vector names, Vector layouts, Vector selects, Vector creates, Vector ids, int mode, String delimiter) throws Exception
138: {
139: bean = source;
140: beanDest = destination;
141: convert(null, null, names, layouts, selects, creates, ids, mode, delimiter);
142: if (true)
143: return;
144: StringBuffer command = null;
145: try
146: {
147: bean.setConnection(source.url);
148: if (names == null)
149: names = bean.getTableNames();
150: //Collections.sort(names);
151: int tbIndex = 1;
152:
153: for (tbIndex = 0; tbIndex < names.size(); ++tbIndex)
154: {
155: Vector[] result = null;
156: try
157: {
158: String query = "select * from " + bean.getQC() + names.get(tbIndex).toString() + bean.getQC();
159: String layout = (layouts.isEmpty()) ? "" : layouts.get(tbIndex).toString();
160: query = (selects != null) ? selects.get(tbIndex).toString() : query;
161: //if vectors[1].get(i) != null)
162: if (!layout.equals(""))
163: {
164: System.out.println("before " + query + " table" + names.get(tbIndex));
165: layout = " layout " + bean.getQC() + layout + bean.getQC();
166: String name = names.get(tbIndex).toString();
167: StringBuffer queryLayout = new StringBuffer(query);
168: queryLayout.insert(queryLayout.indexOf(name) + name.length() + 1, " " + layout);
169: query = queryLayout.toString();
170: System.out.println("added layout " + query);
171:
172: }
173: System.out.println(" performing query " + query);
174: //result = bean.getQueryData(query, null, 0);
175: bean.getConnection();
176: bean.makeQuery(query, 0);
177: }
178: catch (Exception e)
179: {
180: System.out.println(e.getMessage());
181: e.printStackTrace();
182: continue;
183: }
184: //beanDest.setConnection("jdbc:postgresql://erebos/test3");
185: beanDest.setConnection(destination.url);
186:
187: Statement stm = beanDest.getConnection().createStatement();
188:
189: Vector tables = beanDest.getTableNames();
190: // Collections.sort(tables);
191: System.out.println("converting table " + names.get(tbIndex) + " " + tables.indexOf(convertText((String) names.get(tbIndex)))); // "//beanDest.getTypeNames());
192: tables = beanDest.getTableNames();
193: // System.out.println(beanDest.getTableNames(beanDest.getCatalogs().get(2).toString()));
194: stm = beanDest.getConnection().createStatement();
195: // System.exit(0);
196: if (mode == Convert.DataBase.CONVERT_MODE)
197: {
198: if (tables.indexOf(names.get(tbIndex)) >= 0)
199: {
200: stm.executeUpdate("drop table " + beanDest.getQC() + names.get(tbIndex) + beanDest.getQC());
201: tables.remove((String) names.get(tbIndex));
202: System.out.println("dropped table " + names.get(tbIndex));
203: }
204: else if (tables.indexOf(convertText(names.get(tbIndex).toString())) >= 0)
205: {
206: stm.executeUpdate("drop table " + beanDest.getQC() + convertText((String) names.get(tbIndex)) + beanDest.getQC());
207: tables.remove(convertText((String) names.get(tbIndex)));
208: System.out.println("dropped table " + names.get(tbIndex));
209: }
210:
211: if (tables.indexOf(names.get(tbIndex)) < 0 && tables.indexOf(convertText(names.get(tbIndex).toString())) < 0)
212: {
213: if (creates.get(tbIndex).equals("") || creates.get(tbIndex).toString().toLowerCase().indexOf("create") < 0)
214: {
215: System.out.println("Warning empty or invalid create statement - creating one for you\n");
216:
217: command = new StringBuffer(50);
218: command.append("CREATE TABLE ");
219: command.append(beanDest.getQC());
220: command.append(convertText((String) names.get(tbIndex)));
221: command.append(beanDest.getQC());
222: command.append("(");
223: String type = null;
224: Vector columnNames = bean.getColumnNames();
225: for (int i = 0; i < columnNames.size() - 1; ++i)
226: {
227: type = bean.metaData.getColumnTypeName(i + 1);
228: // System.out.println(i+" "+result[1].get(i)+"
229: // "+type);
230: type = (type.equals("NUMBER")) ? "INT4" : type;
231: type = (type.equals("CONTAINER")) ? "TEXT" : type;
232:
233: command.append(beanDest.getQC() + convertText((String) columnNames.get(i)) + beanDest.getQC() + " " + type + ", ");
234: }
235: type = bean.metaData.getColumnTypeName(columnNames.size());
236: type = (type.equals("NUMBER")) ? "INT4" : type;
237: type = (type.equals("CONTAINER")) ? "TEXT" : type;
238: command.append(beanDest.getQC() + convertText((String) columnNames.get(columnNames.size() - 1)) + beanDest.getQC() + " " + type);
239: command.append(" )");
240: }
241: else
242: command = new StringBuffer().append(creates.get(tbIndex).toString());
243:
244: System.out.println(command);
245: // System.exit(0);
246: //command.append(DBBean.getQC());
247: stm.executeUpdate(command.toString());
248:
249: }
250: }
251: Vector row = null;
252: command = new StringBuffer();
253:
254: command.append("INSERT INTO ");
255: command.append(beanDest.getQC());
256: command.append(convertText((String) names.get(tbIndex)));
257: command.append(beanDest.getQC());
258: command.append(" values ( ");
259:
260: for (int i = 0; i < bean.getColumnNames().size() - 1; ++i)
261: command.append("?,");
262: command.append("?)");
263: PreparedStatement pstm = beanDest.getConnection().prepareStatement(command.toString());
264: System.out.println(command);
265: while ((row = bean.getNextRow()) != null)
266: {
267: //print rows
268: Object obj = null;
269: for (int k = 0; k < row.size(); ++k)
270: {
271: obj = row.get(k);
272: if (obj instanceof ArrayList)
273: obj = formatFileMakerArray((List) obj, "\n");
274: String str = (obj == null) ? "NULL" : obj.toString();
275: if (!str.equals("NULL"))
276: pstm.setString(k + 1, str);
277: else
278: pstm.setNull(k + 1, Types.NULL);
279: }
280: pstm.execute();
281:
282: } // to for loop
283:
284: }
285: }
286: catch (Exception e)
287: {
288: System.out.println("Error while connecting to database " + e);
289: //dialog.setVisible(false);
290: //dialog.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
291: //FM2SQL.fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
292: java.io.ByteArrayOutputStream b = new java.io.ByteArrayOutputStream();
293: java.io.PrintStream stream = new java.io.PrintStream(b);
294: stream.print(command + "\n\n");
295: e.printStackTrace(stream);
296: System.err.println(b);
297: //FM2SQL.showErrorDialog(b.toString(), "Error occured !");
298:
299: }
300: // dialog.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
301: //FM2SQL.fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
302:
303: // dialog.setVisible(false);
304: }
305:
306: public static String formatFileMakerArray(List list, String delimiter)
307: {
308: StringBuffer formattedString = new StringBuffer();
309: for (int i = 0; i < list.size(); ++i)
310: {
311: formattedString.append(list.get(i).toString());
312: if (i < list.size() - 1)
313: formattedString.append(delimiter);
314: }
315: return formattedString.toString();
316: }
317:
318: /**
319: * Method for SQL UPDATE
320: *
321: * @param source
322: * @param destination
323: * @param names
324: * @param layouts
325: * @param selects
326: * @param creates
327: * @param ids
328: * @param mode
329: * @throws Exception
330: */
331: public static void update(String source, String destination, Vector names, Vector layouts, Vector selects, Vector creates, Vector ids, int mode) throws Exception
332: {
333:
334: FM2SQL.ProgressDialog dialog = null;
1.83 ! rogo 335: if (isGUI)
1.79 rogo 336: {
337: dialog = new FM2SQL.ProgressDialog(FM2SQL.fmInstance, bean);
338: dialog.setTitle("Conversion running ...");
339: dialog.title.setText("Getting table data ...");
340: dialog.setLocation(FM2SQL.fmInstance.getLocationOnScreen().x + (FM2SQL.fmInstance.getWidth() - 400) / 2, FM2SQL.fmInstance.getLocationOnScreen().y + (FM2SQL.fmInstance.getHeight() - 250) / 2);
341: dialog.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
342: FM2SQL.fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
343: dialog.thread = Thread.currentThread();
344: }
345: // setting user and passwd
346: bean.setUserAndPasswd(user, passwd);
347: // setting user and passwd
348: beanDest.setUserAndPasswd(userDest, passwdDest);
349: if (dialog != null)
350: dialog.setSize(400, 250);
351: StringBuffer command = null;
352: String query = null;
353: try
354: {
355: //bean.setConnection("jdbc:fmpro:http://141.14.237.74:8050");
356: //bean.setConnection("jdbc:postgresql://erebos/test","postgres","rogo");
1.83 ! rogo 357: System.out.println("before getConnection");
! 358:
1.79 rogo 359: bean.setConnection(source);
1.83 ! rogo 360: System.out.println("after getConnection");
! 361:
1.79 rogo 362: if (names == null)
363: names = bean.getTableNames();
364: // Collections.sort(names);
365: int tbIndex = 1;
366:
1.83 ! rogo 367: System.out.println("Start at table "+names.firstElement());
1.79 rogo 368: for (tbIndex = 0; tbIndex < names.size(); ++tbIndex)
369: {
370: Vector[] result = null;
371: String destTableName = "";
372: try
373: {
374: query = "select * from " + bean.getQC() + names.get(tbIndex).toString() + bean.getQC();
375: String layout = (layouts.isEmpty()) ? "" : layouts.get(tbIndex).toString();
376: query = (selects != null) ? selects.get(tbIndex).toString() : query;
377: //if vectors[1].get(i) != null)
378: if (layout != "")
379: {
380: layout = " layout " + bean.getQC() + layout + bean.getQC();
381: String name = names.get(tbIndex).toString();
382: StringBuffer queryLayout = new StringBuffer(query);
383: queryLayout.insert(queryLayout.indexOf(name) + name.length() + 1, " " + layout);
384: query = queryLayout.toString();
385: System.out.println("added layout " + query);
386:
387: }
388: if (dialog != null)
389: {
390: dialog.title.setText("Getting table data ...");
391: dialog.table.setText(names.get(tbIndex).toString());
392: dialog.status.setText("Table " + (tbIndex + 1) + " of " + names.size());
393: dialog.show();
394: }
395: bean.getConnection();
396: bean.makeQuery(query, 0);
397:
398: }
399: catch (Exception e)
400: {
401: continue;
402: }
403: // determine destTableName from createStatement or from source
404: // table name
405: if (!creates.get(tbIndex).equals(""))
406: {
407: String create = creates.get(tbIndex).toString().toLowerCase();
408: int fromIndex = create.indexOf("table") + 5;
409: int toIndex = create.indexOf("(");
410: destTableName = create.substring(fromIndex, toIndex).replaceAll(beanDest.getQC(), "").trim();
411: System.out.println("destTable " + destTableName);
412:
413: }
414: else
415: destTableName = convertText(names.get(tbIndex).toString());
416:
417: //beanDest.setConnection("jdbc:postgresql://erebos/test3");
418: beanDest.setConnection(destination);
419:
420: Statement stm = beanDest.getConnection().createStatement();
421:
422: Vector tables = beanDest.getTableNames();
423: // Collections.sort(tables);
424: System.out.println(names.get(tbIndex) + " " + tables.indexOf(convertText((String) names.get(tbIndex)))); // "//beanDest.getTypeNames());
425: tables = beanDest.getTableNames();
426: // System.out.println(beanDest.getTableNames(beanDest.getCatalogs().get(2).toString()));
427: stm = beanDest.getConnection().createStatement();
428: // System.exit(0);
429:
430: if (dialog != null)
431: dialog.title.setText("Updating table data ...");
1.83 ! rogo 432: else System.out.println("Updating table data ...");
1.79 rogo 433: int j = -1;
434:
435: Vector row = null;
436: command = new StringBuffer();
437:
438: command.append("UPDATE ");
439: command.append(beanDest.getQC());
440: command.append(destTableName);
441: //command.append(convertText((String) names.get(tbIndex)));
442: command.append(beanDest.getQC());
443: command.append(" SET ");
444:
445: int size = bean.getColumnNames().size();
446: for (int i = 0; i < size - 1; ++i)
447: command.append(beanDest.getQC() + convertText((String) bean.getColumnNames().get(i)) + beanDest.getQC() + " = ? ,");
448: command.append(convertText((String) bean.getColumnNames().get(size - 1)) + " = ? ");
449: command.append("WHERE " + convertText(ids.get(tbIndex).toString()) + " = ?");
450: PreparedStatement pstm = beanDest.getConnection().prepareStatement(command.toString());
451: System.out.println(command + " " + tbIndex);
452: int rowCount = bean.getRowCount(query);
453: int idIndex = bean.getColumnNames().indexOf(ids.get(tbIndex));
454: while ((row = bean.getNextRow()) != null)
455: {
456: j++;
457: //print rows
458: Object obj = null;
459: /*
460: * for(int k=0;k <row.size()-1;++k) { obj = row.get(k);
461: * //System.out.println("row "+obj+" "+k); if(obj!=null&&!(obj
462: * instanceof ArrayList))
463: * command.append("'"+convertUml(obj.toString())+"',"); else
464: * if(obj!=null&& obj instanceof ArrayList)
465: * command.append("'"+convertUml(((ArrayList)obj).get(0).toString())+"',");
466: * else command.append("NULL,"); } obj = row.get(row.size() - 1); if
467: * (obj != null && !(obj instanceof ArrayList))
468: * command.append("'"+convertUml(obj.toString())+"')"); else
469: * if(obj!=null&& obj instanceof ArrayList)
470: * command.append("'"+convertUml(((ArrayList)obj).get(0).toString())+"')");
471: * //command.append(obj.toString()+")"); else command.append("NULL)");
472: */
473: //command.append("'"+row.get(row.size()-1)+"')");
474: //command.append(" )");
475: // for(int k=0;k<row.size();++k)
476: // System.out.println();
477: // System.out.println(command+" "+j+" "+row.size()+" "+
478: // ((Vector)result2[0].get(j)).size());
479: // System.out.println(command);
480: for (int k = 0; k < row.size(); ++k)
481: {
482: obj = row.get(k);
483: if (obj instanceof ArrayList)
484: obj = ((List) obj).get(0);
485: String str = (obj == null) ? "NULL" : obj.toString();
486: if (!str.equals("NULL"))
487: pstm.setString(k + 1, str);
488: else
489: pstm.setNull(k + 1, Types.NULL);
490: }
491: pstm.setString(row.size() + 1, row.get(idIndex).toString());
492: //System.out.println(pstm.toString());
493: // System.exit(0);
494: pstm.execute();
495: //stm.executeUpdate(command.toString());
496: if (dialog != null)
497: dialog.progress.setValue((int) (((double) (j + 1) / (double) rowCount) * 100.0));
498: // System.out.println(
499: // (int)(((double)(j+1)/(double)result[0].size())*100.0)+"
500: // "+result[0].size()+" "+j);
501: command = null;
502: } // to for loop
503:
504: }
505: }
506: catch (Exception e)
507: {
508: System.out.println("Error while connecting to database " + e);
509: if (dialog != null)
510: {
511: dialog.setVisible(false);
512: dialog.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
513: FM2SQL.fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
514: }
515: java.io.ByteArrayOutputStream b = new java.io.ByteArrayOutputStream();
516: java.io.PrintStream stream = new java.io.PrintStream(b);
517: stream.print(command + "\n\n");
518: e.printStackTrace(stream);
1.83 ! rogo 519: if(dialog!=null)
1.79 rogo 520: FM2SQL.showErrorDialog(b.toString(), "Error occured !");
521:
522: }
523: if (dialog != null)
524: {
525: dialog.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
526: FM2SQL.fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
527:
528: dialog.setVisible(false);
529: }
530:
531: }
532:
533: /**
534: * transfers the specified array of tables to the destination database and
535: * creates the table if it does not exist if it exists and mode is not append
536: * the table is dropped
537: *
538: * @param source
539: * @param destination
540: * @param names
541: * @param layouts
542: * @param selects
543: * @param creates
544: * @param ids
545: * @param mode
546: * @throws Exception
547: */
548:
549: public static void convert(String source, String destination, Vector names, Vector layouts, Vector selects, Vector creates, Vector ids, int mode, String delimiter) throws Exception
550: {
1.83 ! rogo 551:
1.79 rogo 552: FM2SQL.ProgressDialog dialog = null;
553:
1.83 ! rogo 554: if (isGUI)
1.79 rogo 555: {
556: dialog = new FM2SQL.ProgressDialog(FM2SQL.fmInstance, bean);
557: dialog.setTitle("Conversion running ...");
558: dialog.title.setText("Getting table data ...");
559: dialog.setLocation(FM2SQL.fmInstance.getLocationOnScreen().x + (FM2SQL.fmInstance.getWidth() - 400) / 2, FM2SQL.fmInstance.getLocationOnScreen().y + (FM2SQL.fmInstance.getHeight() - 250) / 2);
560: dialog.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
561: FM2SQL.fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
562: dialog.thread = Thread.currentThread();
563: dialog.setSize(400, 250);
564: }
1.83 ! rogo 565:
! 566: System.out.println("connection established "+source+" "+bean.url);
! 567:
1.79 rogo 568: java.util.TreeSet myIds = new TreeSet();
569: int deltaID = 1;
570: String idField = "";
571: String destTableName = "";
572: String[] fieldNames = null;
1.83 ! rogo 573:
1.79 rogo 574: if (source != null && destination != null)
575: {
576: // setting user and passwd
577: bean.setUserAndPasswd(user, passwd);
578: // setting user and passwd
579: beanDest.setUserAndPasswd(userDest, passwdDest);
580: }
1.83 ! rogo 581:
1.79 rogo 582: StringBuffer command = null;
583: String query = null;
584: try
585: {
1.83 ! rogo 586:
1.79 rogo 587: if (source != null)
588: bean.setConnection(source);
589: else
590: bean.setConnection(bean.url);
1.83 ! rogo 591: if (names == null)
1.79 rogo 592: names = bean.getTableNames();
593: // Collections.sort(names);
594: int tbIndex = 1;
595:
596: // System.out.println("Start at
597: // "+names.indexOf("archimedes_facsimiles"));
598: for (tbIndex = 0; tbIndex < names.size(); ++tbIndex)
599: {
600: Vector[] result = null;
601: try
602: {
603: query = "select * from " + bean.getQC() + names.get(tbIndex).toString() + bean.getQC();
604: String layout = (layouts.isEmpty()) ? "" : layouts.get(tbIndex).toString();
605: query = (selects != null) ? selects.get(tbIndex).toString() : query;
606: //if vectors[1].get(i) != null)
607: if (layout != "")
608: {
609: layout = " layout " + bean.getQC() + layout + bean.getQC();
610: String name = names.get(tbIndex).toString();
611: StringBuffer queryLayout = new StringBuffer(query);
612: queryLayout.insert(queryLayout.indexOf(name) + name.length() + 1, " " + layout);
613: query = queryLayout.toString();
614: System.out.println("added layout " + query);
615:
616: }
617: // if ( layout!= "")
618: // query += " layout " + bean.getQC() + layout +
619: // bean.getQC();
620: if (dialog != null)
621: {
622: dialog.title.setText("Reading table data ...");
623: dialog.table.setText(names.get(tbIndex).toString());
624: dialog.status.setText("Table " + (tbIndex + 1) + " of " + names.size());
625: dialog.show();
626: }
627: //result = bean.getQueryData(query, dialog, 0);
628: bean.getConnection();
629: bean.makeQuery(query, 50);
630: idField = ids.get(tbIndex).toString();
631:
632: }
633: catch (Exception e)
634: {
635: System.out.println(e);
636: continue;
637: }
638: if (destination != null)
639: beanDest.setConnection(destination);
640: else
641: beanDest.setConnection(beanDest.url);
642: Statement stm = beanDest.getConnection().createStatement();
643:
644: Vector tables = beanDest.getTableNames();
645: // Collections.sort(tables);
646: System.out.println(names.get(tbIndex) + " " + tables.indexOf(convertText((String) names.get(tbIndex)))); // "//beanDest.getTypeNames());
647: tables = beanDest.getTableNames();
648: // System.out.println(beanDest.getTableNames(beanDest.getCatalogs().get(2).toString()));
649: stm = beanDest.getConnection().createStatement();
650: // System.exit(0);
651:
652: // determine destTableName from createStatement or from source
653: // table name
654: ConversionProperties prop = getFieldNamesAndDestTableName(creates.get(tbIndex).toString(), query, names.get(tbIndex).toString());
655: destTableName = prop.destTableName;
656: fieldNames = prop.fieldNames;
657: if (mode == Convert.DataBase.CONVERT_MODE)
658: {
659:
660: if (tables.indexOf(destTableName) >= 0)
661: {
662: stm.executeUpdate("drop table " + beanDest.getQC() + destTableName + beanDest.getQC());
663: tables.remove(destTableName);
664: System.out.println("dropped table" + destTableName);
665:
666: }
667: /*
668: * if(destTableName.equals("")) if (tables.indexOf(names.get(tbIndex)) >=
669: * 0) { stm.executeUpdate("drop table " + beanDest.getQC() +
670: * names.get(tbIndex) + beanDest.getQC()); tables.remove((String)
671: * names.get(tbIndex)); System.out.println("dropped table" +
672: * names.get(tbIndex)); } else if
673: * (tables.indexOf(convertText(names.get(tbIndex).toString())) >= 0) {
674: * stm.executeUpdate("drop table " + beanDest.getQC() +
675: * convertText((String) names.get(tbIndex)) + beanDest.getQC());
676: * tables.remove(convertText((String) names.get(tbIndex)));
677: * System.out.println("dropped table" + names.get(tbIndex)); }
678: */
679: if ((tables.indexOf(destTableName) < 0)) //&&
680: // tables.indexOf(names.get(tbIndex))
681: // < 0 &&
682: // tables.indexOf(convertText(names.get(tbIndex).toString()))
683: // < 0 )
684: {
685:
686: if (creates.get(tbIndex).equals("") || creates.get(tbIndex).toString().toLowerCase().indexOf("create") < 0)
687: {
688: System.out.println("Warning empty or invalid create statement - creating one for you\n");
689:
690: command = new StringBuffer(50);
691: command.append("CREATE TABLE ");
692: command.append(beanDest.getQC());
693: command.append(convertText((String) names.get(tbIndex)));
694: command.append(beanDest.getQC());
695: command.append("(");
696: String type = null;
697: Vector columnNames = bean.getColumnNames();
698: for (int i = 0; i < columnNames.size() - 1; ++i)
699: {
700: type = bean.metaData.getColumnTypeName(i + 1);
701: // System.out.println(i+" "+result[1].get(i)+"
702: // "+type);
703: type = (type.equals("NUMBER")) ? "INT4" : type;
704: type = (type.equals("CONTAINER")) ? "TEXT" : type;
705:
706: command.append(beanDest.getQC() + convertText((String) columnNames.get(i)) + beanDest.getQC() + " " + type + ", ");
707: }
708: type = bean.metaData.getColumnTypeName(columnNames.size());
709: type = (type.equals("NUMBER")) ? "INT4" : type;
710: type = (type.equals("CONTAINER")) ? "TEXT" : type;
711: command.append(beanDest.getQC() + convertText((String) columnNames.get(columnNames.size() - 1)) + beanDest.getQC() + " " + type);
712: command.append(" )");
713:
714: // System.out.println(command);
715: // System.exit(0);
716: //command.append(DBBean.getQC());
717: }
718: else
719: command = new StringBuffer().append(creates.get(tbIndex).toString().toLowerCase());
720: stm.executeUpdate(command.toString());
721:
722: }
723: }
724: if (dialog != null)
725: dialog.title.setText("Writing table data ...");
726:
727: // prepare the insert statement
728: int j = -1;
729: Vector row = null;
730: command = new StringBuffer();
731:
732: command.append("INSERT INTO ");
733: command.append(beanDest.getQC());
734: command.append(destTableName); //convertText((String)
735: // names.get(tbIndex)));
736: command.append(beanDest.getQC());
737: command.append(" (");
738: for (int i = 0; i < fieldNames.length; i++)
739: {
740: command.append(fieldNames[i]);
741: if (i < fieldNames.length - 1)
742: command.append(",");
743: }
744: command.append(") ");
745:
746: command.append(" values ( ");
747:
748: // add a question marks for every field
749: for (int i = 0; i < bean.getColumnNames().size() - 1; ++i)
750: command.append("?,");
751: command.append("?)");
752: PreparedStatement pstm = beanDest.getConnection().prepareStatement(command.toString());
753: System.out.println(command);
754: int rowCount = (idField != "") ? myIds.size() : bean.getRowCount(query);
755: Vector vec = new Vector(myIds);
756: int endIndex = -1;
757: String tempQuery = query;
758: String tempID = bean.getQC() + idField + bean.getQC();
759: // if id_field not do incremental conversion else do it all at
760: // once
761: if (!idField.equals(""))
762: {
763: long startTime = System.currentTimeMillis();
764: int counter = -1;
765: while (true)
766: {
767: ++counter;
768: if (counter == 0 && dialog != null)
769: dialog.title.setText("Check if data is available");
770: else if (dialog != null)
771: dialog.title.setText("Check if more data is available");
772: myIds = bean.getIDVector(ids.get(tbIndex).toString(), (String) names.get(tbIndex), tempQuery, numHits);
773: if (myIds.isEmpty())
774: break;
775: vec = new Vector(myIds);
776: rowCount = vec.size();
777: System.out.println("ID LIST SIZE " + Math.round((double) myIds.size() / (double) numIntervalls) + " " + myIds.size());
778: deltaID = (int) Math.round((double) myIds.size() / (double) numIntervalls);
779: if (vec.size() <= numIntervalls)
780: {
781: endIndex = 0;
782: deltaID = vec.size();
783: }
784: for (int k = 0; k < vec.size() - deltaID; k = k + deltaID)
785: {
786: System.out.println(vec.get(k) + " " + vec.get(k + deltaID) + " " + vec.lastElement());
787: if (query.indexOf("where") > 0)
788: tempQuery = query + " and " + tempID + ">='" + vec.get(k) + "' and " + tempID + "<='" + vec.get(k + deltaID) + "'";
789: else
790: tempQuery = query + " where " + tempID + ">='" + vec.get(k) + "' and " + tempID + "<='" + vec.get(k + deltaID) + "'";
791: System.out.println(tempQuery);
792: if (dialog != null)
793: dialog.title.setText("Reading table data ...");
794:
795: bean.makeQuery(tempQuery, deltaID);
796: if (dialog != null)
797: dialog.title.setText("Writing table data ...");
798:
799: command = writeDatainDestTable(dialog, command, k, pstm, rowCount, delimiter);
800: endIndex = k + deltaID;
801: }
802: System.out.println(endIndex);
803: //all data written ? if not write last chunk of data
804: if (endIndex == vec.size() - 1)
805: System.out.println("fits");
806: else
807: {
808: System.out.println(" last intervall from " + vec.get(endIndex) + " " + vec.lastElement());
809:
810: if (query.indexOf("where") > 0)
811: tempQuery = query + " and " + tempID + ">='" + vec.get(endIndex) + "' and " + tempID + "<='" + vec.lastElement() + "'";
812: else
813: tempQuery = query + " where " + tempID + ">='" + vec.get(endIndex) + "' and " + tempID + "<='" + vec.lastElement() + "'";
814: System.out.println(tempQuery);
815: if (dialog != null)
816: dialog.title.setText("Reading table data ...");
817: bean.makeQuery(tempQuery, 0);
818: if (dialog != null)
819: dialog.title.setText("Writing table data ...");
820: command = writeDatainDestTable(dialog, command, endIndex, pstm, rowCount, delimiter);
821: }
822: // prepare new query for next chunk
823: if (query.indexOf("where") > 0)
824: tempQuery = query + " and " + tempID + ">'" + vec.lastElement() + "'";
825: else
826: tempQuery = query + " where " + tempID + ">'" + vec.lastElement() + "'";
827:
828: }
829: long endTime = System.currentTimeMillis();
830: System.out.println("Time for incremental convert elapsed " + (endTime - startTime));
831: }
832: else
833: {
834: // read and write all in one big chunk
835: long startTime = System.currentTimeMillis();
836:
837: bean.makeQuery(query, 0);
838: command = writeDatainDestTable(dialog, command, j, pstm, rowCount, delimiter);
839: long endTime = System.currentTimeMillis();
840: System.out.println("Time for old convert elapsed " + (endTime - startTime));
841:
842: }
843: }
844: }
845: catch (Exception e)
846: {
847: System.out.println("Error while connecting to database " + e);
848: if (dialog != null)
849: {
850: dialog.setVisible(false);
851: dialog.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
852: FM2SQL.fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
853: java.io.ByteArrayOutputStream b = new java.io.ByteArrayOutputStream();
854: java.io.PrintStream stream = new java.io.PrintStream(b);
855: stream.print(command + "\n\n");
856: e.printStackTrace(stream);
857: FM2SQL.showErrorDialog(b.toString(), "Error occured !");
858: }
859: else
860: {
861: e.printStackTrace();
862:
863: }
864: }
865: if (dialog != null)
866: {
867: dialog.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
868: FM2SQL.fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
869: dialog.setVisible(false);
870: }
871: }
872:
873: /**
874: * Writes data to the destination table
875: *
876: * @param dialog
877: * progress dialog
878: * @param command
879: * @param j
880: * data index for progress bar
881: * @param pstm
882: * prepared statement
883: * @param rowCount
884: * number of datasets
885: * @return command
886: * @throws Exception
887: * @throws SQLException
888: */
889: private static StringBuffer writeDatainDestTable(FM2SQL.ProgressDialog dialog, StringBuffer command, int j, PreparedStatement pstm, int rowCount, String delimiter) throws Exception, SQLException
890: {
891: Vector row;
892: while ((row = bean.getNextRow()) != null)
893: {
894: j++;
895: // row = (Vector) result[0].get(j);
896: /*
897: * command = new StringBuffer();
898: *
899: * command.append("INSERT INTO "); command.append(beanDest.getQC());
900: * command.append(convertText((String) names.get(tbIndex)));
901: * command.append(beanDest.getQC()); command.append(" values ( ");
902: */
903: //print rows
904: Object obj = null;
905: /*
906: * for(int k=0;k <row.size()-1;++k) { obj = row.get(k);
907: * //System.out.println("row "+obj+" "+k); if(obj!=null&&!(obj instanceof
908: * ArrayList)) command.append("'"+convertUml(obj.toString())+"',"); else
909: * if(obj!=null&& obj instanceof ArrayList)
910: * command.append("'"+convertUml(((ArrayList)obj).get(0).toString())+"',");
911: * else command.append("NULL,"); } obj = row.get(row.size() - 1); if (obj !=
912: * null && !(obj instanceof ArrayList))
913: * command.append("'"+convertUml(obj.toString())+"')"); else
914: * if(obj!=null&& obj instanceof ArrayList)
915: * command.append("'"+convertUml(((ArrayList)obj).get(0).toString())+"')");
916: * //command.append(obj.toString()+")"); else command.append("NULL)");
917: */
918: //command.append("'"+row.get(row.size()-1)+"')");
919: //command.append(" )");
920: // for(int k=0;k<row.size();++k)
921: // System.out.println();
922: // System.out.println(command+" "+j+" "+row.size()+" "+
923: // ((Vector)result2[0].get(j)).size());
924: // System.out.println(command);
925: for (int k = 0; k < row.size(); ++k)
926: {
927: obj = row.get(k);
928:
929: if (obj instanceof ArrayList)
930: obj = formatFileMakerArray((List) obj, delimiter);
931:
932: String str = (obj == null) ? "NULL" : obj.toString();
933: if (obj instanceof Double)
934: {
935: pstm.setDouble(k + 1, ((Double) obj).doubleValue());
936: }
937: else if (!str.equals("NULL"))
938: pstm.setString(k + 1, str);
939: else
940: pstm.setNull(k + 1, Types.NULL);
941: }
942: pstm.execute();
943: //stm.executeUpdate(command.toString());
944: if (dialog != null)
945: dialog.progress.setValue((int) (((double) (j + 1) / (double) rowCount) * 100.0));
946: // System.out.println(
947: // (int)(((double)(j+1)/(double)result[0].size())*100.0)+"
948: // "+result[0].size()+" "+j);
949: command = null;
950: } // to while loop
951: return command;
952: }
953:
954: /**
955: * removes special characters from the input string as well as .fp5
956: *
957: * @param newName
958: * String to change
959: * @return
960: */
961: public static String convertText(String newName)
962: {
963: StringBuffer alterMe = new StringBuffer(newName.trim().toLowerCase());
964: int length = alterMe.length();
965: int j = 0;
966: int index = alterMe.indexOf(".fp5");
967: if (index >= 0)
968: {
969: alterMe.delete(index, index + 4);
970: length = length - 4;
971: }
972:
973: while (j < length)
974: {
975: if (alterMe.charAt(j) == ' ')
976: {
977: alterMe.setCharAt(j, '_');
978: // if(j<length-1) j=j+1;
979: }
980: else if (alterMe.charAt(j) == '_')
981: {
982:
983: if (alterMe.charAt(j + 1) == '_')
984: alterMe.deleteCharAt(j);
985: length = length - 1;
986: // if(j<length-1) j=j+1;
987: }
988: else if (alterMe.charAt(j) == 'ä')
989: {
990: alterMe.setCharAt(j, 'a');
991: alterMe.insert(j + 1, "e");
992: length = length + 1;
993: if (j < length - 1)
994: j = j + 1;
995: }
996: else if (alterMe.charAt(j) == 'ö')
997: {
998: alterMe.setCharAt(j, 'o');
999: alterMe.insert(j + 1, "e");
1000: length = length + 1;
1001: if (j < length - 1)
1002: j = j + 1;
1003: }
1004: else if (alterMe.charAt(j) == 'ü')
1005: {
1006: alterMe.setCharAt(j, 'u');
1007: alterMe.insert(j + 1, "e");
1008: length = length + 1;
1009: if (j < length - 1)
1010: j = j + 1;
1011: }
1012: else if (alterMe.charAt(j) == 'ß')
1013: {
1014: alterMe.setCharAt(j, 's');
1015: alterMe.insert(j + 1, "s");
1016: length = length + 1;
1017: if (j < length - 1)
1018: j = j + 1;
1019: }
1020: else if (alterMe.charAt(j) == ':')
1021: {
1022: if (j < length - 1)
1023: {
1024: if (alterMe.charAt(j + 1) == ':')
1025: {
1026: alterMe.setCharAt(j, '_');
1027: alterMe.delete(j + 1, j + 2);
1028: length = length - 1;
1029:
1030: }
1031:
1032: if (j < length - 1)
1033: j = j + 1;
1034: }
1035: }
1036: else if (alterMe.charAt(j) == '-')
1037: {
1038: alterMe.setCharAt(j, '_');
1039:
1040: }
1041: else if (alterMe.charAt(j) == '?')
1042: {
1043: // changed ? to _ because of update statement
1044: alterMe.setCharAt(j, '_');
1045: // length = length + 1;
1046: // j=j+1;
1047: System.out.println(alterMe);
1048: }
1049: else if (alterMe.charAt(j) == '.')
1050: {
1051: if (j == length - 1)
1052: {
1053: alterMe.delete(j, j);
1054: length--;
1055: }
1056: else
1057: alterMe.setCharAt(j, '_');
1058: }
1059:
1060: ++j;
1061: }
1062: return alterMe.toString();
1063: }
1064:
1065: /**
1066: * Converts > and < in an entity (> or <)
1067: *
1068: * @param newName
1069: * @return
1070: */
1071: public static String convertToEntities(String newName)
1072: {
1073: StringBuffer alterMe = new StringBuffer(newName.trim());
1074: int length = alterMe.length();
1075: int j = 0;
1076:
1077: while (j < length)
1078: {
1079:
1080: if (alterMe.charAt(j) == '>')
1081: {
1082: alterMe.setCharAt(j, '&');
1083: alterMe.insert(j + 1, "gt;");
1084: length = length + 2;
1085: if (j < length - 1)
1086: j = j + 1;
1087:
1088: }
1089: else if (alterMe.charAt(j) == '<')
1090: {
1091: alterMe.setCharAt(j, '&');
1092: alterMe.insert(j + 1, "lt;");
1093: length = length + 2;
1094: if (j < length - 1)
1095: j = j + 1;
1096:
1097: }
1098: ++j;
1099: }
1100: return alterMe.toString();
1101: }
1102:
1103: /**
1104: * Masks the single quote character '-->\'
1105: *
1106: * @param newName
1107: * @return
1108: */
1109: public static String convertUml(String newName)
1110: {
1111: StringBuffer alterMe = new StringBuffer(newName.trim());
1112: int length = alterMe.length();
1113: int j = 0;
1114:
1115: while (j < length)
1116: {
1117:
1118: if (alterMe.charAt(j) == '\'')
1119: {
1120: alterMe.setCharAt(j, '\\');
1121: alterMe.insert(j + 1, "'");
1122: length = length + 1;
1123: if (j < length - 1)
1124: j = j + 1;
1125: }
1126: /*
1127: * else if (alterMe.charAt(j) == '"') { alterMe.setCharAt(j, '\\');
1128: * alterMe.insert(j + 1, "\""); length = length + 1; if(j <length-1)
1129: * j=j+1; } else if (alterMe.charAt(j) == '>') { alterMe.setCharAt(j,
1130: * '\\'); alterMe.insert(j + 1, ">"); length = length + 1; if(j <length-1)
1131: * j=j+1; } else if (alterMe.charAt(j) == ' <') { alterMe.setCharAt(j,
1132: * '\\'); alterMe.insert(j + 1, " <"); length = length + 1; if(j
1133: * <length-1) j=j+1; } else if (alterMe.charAt(j) == '?') {
1134: * alterMe.setCharAt(j, '\\'); alterMe.insert(j + 1, "?"); length = length +
1135: * 1; if(j <length-1) j=j+1; } else if (alterMe.charAt(j) == '&') {
1136: * alterMe.setCharAt(j, '\\'); alterMe.insert(j + 1, "&"); length = length +
1137: * 1; if(j <length-1) j=j+1; } else if (alterMe.charAt(j) == '=') {
1138: * alterMe.setCharAt(j, '\\'); alterMe.insert(j + 1, "="); length = length +
1139: * 1; if(j <length-1) j=j+1; } else if (alterMe.charAt(j) == ',') {
1140: * alterMe.setCharAt(j, '\\'); alterMe.insert(j + 1, ","); length = length +
1141: * 1; if(j <length-1) j=j+1; } else if (alterMe.charAt(j) == '.') {
1142: * alterMe.setCharAt(j, '\\'); alterMe.insert(j + 1, "."); length = length +
1143: * 1; if(j <length-1) j=j+1; } else if (alterMe.charAt(j) == '[') {
1144: * alterMe.setCharAt(j, '\\'); alterMe.insert(j + 1, "."); length = length +
1145: * 1; if(j <length-1) j=j+1; } else if (alterMe.charAt(j) == ']') {
1146: * alterMe.setCharAt(j, '\\'); alterMe.insert(j + 1, "."); length = length +
1147: * 1; if(j <length-1) j=j+1; } else if (alterMe.charAt(j) == '%') {
1148: * alterMe.setCharAt(j, '\\'); alterMe.insert(j + 1, "%"); length = length +
1149: * 1; if(j <length-1) j=j+1; }
1150: */
1151: ++j;
1152: }
1153: return alterMe.toString();
1154: }
1155:
1156: /**
1157: * parses the input xml file for batch conversion called from readXMLFile *
1158: *
1159: * @param sb
1160: */
1161: public static void parseXMLConfig(StringBuffer sb)
1162: {
1163: boolean finished = false;
1164: // parse string and build document tree
1165: Xparse parser = new Xparse();
1166: parser.changeEntities = true;
1167: Node root = parser.parse(sb.toString());
1168: // printContents(root);
1169: Vector databases = new Vector();
1170: Vector tables = new Vector();
1171: Vector layouts = new Vector();
1172: Vector selects = new Vector();
1173: Vector creates = new Vector();
1174: Vector ids = new Vector();
1175: Vector indexListVec = new Vector();
1176: String delimiter = "|";
1177: int mode = -1;
1178:
1179: try
1180: {
1181: Node tempNode = root.find("convert/source", new int[]
1182: {1, 1});
1183: if (tempNode == null)
1184: throw new Error("parse error source tag missing");
1185: System.out.println(tempNode.name);
1186: int length = countNodes(tempNode);
1187: for (int i = 1; i <= length; i++)
1188: {
1189:
1190: DBBean database = new DBBean();
1191: tables = new Vector();
1192: layouts = new Vector();
1193: selects = new Vector();
1194: creates = new Vector();
1195: ids = new Vector();
1196: indexListVec = new Vector();
1197: // parse dataBase
1198: Node node = root.find("convert/source/database/url", new int[]
1199: {1, 1, i, 1});
1200: Node node1 = root.find("convert/source/database/user", new int[]
1201: {1, 1, i, 1, 1});
1202: Node node2 = root.find("convert/source/database/password", new int[]
1203: {1, 1, i, 1, 1});
1204: Node node3 = root.find("convert/source/database", new int[]
1205: {1, 1, i});
1206: Node nodeMode = root.find("convert/source/database/mode", new int[]
1207: {1, 1, i, 1, 1});
1208: Node delimiterNode = root.find("convert/source/database/delimiter", new int[]
1209: {1, 1, i, 1, 1});
1210: Node useNormanToUnicodeMapper = root.find("convert/source/database/usenormantounicodemapper", new int[]
1211: {1, 1, i, 1, 1});
1212:
1213: if (node3 == null)
1214: throw new Error("parse error database tag missing");
1215: if (node == null)
1216: throw new Error("parse error url tag missing");
1217: if (node1 == null)
1218: throw new Error("parse error user tag missing");
1219: if (node2 == null)
1220: throw new Error("parse error password tag missing");
1221: if (delimiterNode != null)
1222: delimiter = delimiterNode.getCharacters();
1223: if (useNormanToUnicodeMapper != null)
1224: {
1225: database.setUseNormanToUnicodeMapper(Boolean.valueOf(useNormanToUnicodeMapper.getCharacters()).booleanValue());
1226: System.out.println("useMapper " + Boolean.valueOf(useNormanToUnicodeMapper.getCharacters().trim()).booleanValue());
1227: }
1228:
1229: String url = node.getCharacters();
1230: String user = node1.getCharacters();
1231: String password = node2.getCharacters();
1232: database.setURL(url.trim());
1233: database.setUserAndPasswd(user.trim(), password.trim());
1234: System.out.println(node.name + " " + node.getCharacters());
1235: System.out.println(node1.name + " " + node1.getCharacters());
1236: System.out.println(node2.name + " " + node2.getCharacters());
1237: String modeString = "";
1238: if (nodeMode == null)
1239: modeString = "convert";
1240: else
1241: modeString = nodeMode.getCharacters();
1242: if (modeString.equals("convert"))
1243: mode = DataBase.CONVERT_MODE;
1244: else if (modeString.equals("append"))
1245: mode = DataBase.APPEND_MODE;
1246: else if (modeString.equals("update"))
1247: mode = DataBase.UPDATE_MODE;
1248: else if (modeString.equals("delete"))
1249: mode = DataBase.DELETE_MODE;
1250: else if (modeString.equals("synchronize"))
1251: mode = DataBase.SYNCHRONIZE_MODE;
1252:
1253: // if(node3!=null)
1254: // System.out.println(node3.name);
1255:
1256: int length2 = countNodes(node3);
1257:
1258: System.out.println("number of tables " + length2);
1259:
1260: for (int j = 1; j <= length2; ++j)
1261: {
1262: Node node4 = root.find("convert/source/database/table", new int[]
1263: {1, 1, i, j});
1264: Node node5 = root.find("convert/source/database/table/select", new int[]
1265: {1, 1, i, j, 1});
1266: Node node6 = root.find("convert/source/database/table/create", new int[]
1267: {1, 1, i, j, 1});
1268: if (node4 != null)
1269: System.out.println(node4.name + " " + node4.attributes.get("layout").equals(""));
1270: if (node5 != null)
1271: System.out.println(node5.name + " " + node5.getCharacters());
1272: if (node6 != null)
1273: System.out.println(node6.name + " " + node6.getCharacters());
1274: if (node4 == null)
1275: throw new Error("parse error table tag missing");
1276: // if(node5==null) throw new Error("parse error select tag
1277: // missing");
1278: // if(node6==null) throw new Error("parse error create tag
1279: // missing");
1280: String name = (String) node4.attributes.get("name");
1281: String layout = (String) node4.attributes.get("layout");
1282: String id = (String) node4.attributes.get("id");
1283: String indexList = (String) node4.attributes.get("indexList");
1284:
1285: System.out.println("id was " + id);
1286: if (name == null)
1287: throw new Error("parse error required table tag attribute name missing");
1288: if (layout == null)
1289: layout = "";
1290: if (id == null)
1291: id = "";
1292: if (indexList == null)
1293: indexList = "";
1294: if (name.equals(""))
1295: throw new Error("parse error table tag attribute must not be empty");
1296: tables.add(name);
1297: layouts.add(layout);
1298:
1299: ids.add(id);
1300: indexListVec.add(indexList);
1301: String query = (node5 == null) ? "" : node5.getCharacters();
1302: if (query.equals(""))
1303: System.err.println("Warning empty select tag or select tag missing !!");
1304: query = (query.equals("")) ? "select * from " + database.getQC() + name + database.getQC() : query;
1305: selects.add(query);
1306: if (node6 != null)
1307: creates.add(node6.getCharacters().trim());
1308: else
1309: creates.add("");
1310:
1311: }
1312: DataBase dataBase = new DataBase(database, tables, layouts, selects, creates, ids, mode);
1313: dataBase.delimiter = delimiter;
1314: dataBase.buildIndexTable(indexListVec);
1315: databases.add(dataBase);
1316: }
1317: DBBean database = new DBBean();
1318: // parse dataBase
1319: Node node = root.find("convert/destination/database/url", new int[]
1320: {1, 1, 1, 1});
1321: Node node1 = root.find("convert/destination/database/user", new int[]
1322: {1, 1, 1, 1, 1});
1323: Node node2 = root.find("convert/destination/database/password", new int[]
1324: {1, 1, 1, 1, 1});
1325: String url = node.getCharacters();
1326: String user = node1.getCharacters();
1327: String password = node2.getCharacters();
1.83 ! rogo 1328: System.out.println(" The url is "+url);
1.79 rogo 1329: database.setURL(url.trim());
1330: database.setUserAndPasswd(user.trim(), password.trim());
1.83 ! rogo 1331: System.out.println("huhu");
1.79 rogo 1332: //databases.add(database);
1333: for (Iterator iter = databases.iterator(); iter.hasNext();)
1334: {
1.83 ! rogo 1335: System.out.println("huhu argghhhh"+(mode == DataBase.CONVERT_MODE)+" mode is "+mode);
! 1336:
1.79 rogo 1337: DataBase db = (DataBase) iter.next();
1338: if (mode == DataBase.CONVERT_MODE || mode == DataBase.APPEND_MODE)
1339: convertBatch(db.bean, database, db.tables, db.layouts, db.selects, db.creates, db.ids, mode, db.delimiter);
1340: else if (mode == DataBase.UPDATE_MODE)
1341: {
1.83 ! rogo 1342: System.out.println("huhu arghhh arghhh arghhh");
! 1343:
1.79 rogo 1344: Convert.user = db.bean.user;
1345: Convert.passwd = db.bean.passwd;
1346: userDest = database.user;
1347: passwdDest = database.passwd;
1348:
1349: update(db.bean.url, database.url, db.tables, db.layouts, db.selects, db.creates, db.ids, mode);
1350: }
1351: else if (mode == DataBase.SYNCHRONIZE_MODE)
1352: {
1353: Convert.user = db.bean.user;
1354: Convert.passwd = db.bean.passwd;
1355: userDest = database.user;
1356: passwdDest = database.passwd;
1357:
1358: synchronize(db.bean.url, database.url, db.tables, db.layouts, db.selects, db.creates, db.ids, mode, db.delimiter, new Vector(db.htIndex.values()));
1359: }
1360: }
1361: // printContents(node3);
1362: // FM2SQL.fmInstance=new FM2SQL();
1363: }
1364: catch (Exception e)
1365: {
1366:
1367: e.printStackTrace();
1368:
1369: } finally
1370: {
1371: bean.closeAllConnections();
1372: beanDest.closeAllConnections();
1373: }
1374: }
1375:
1376: public static Vector getXMLConfig(String xmlFile)
1377: {
1378: StringBuffer sb = null;
1379: try
1380: {
1381: // read XML Metadata from a file
1382: FileInputStream fi = new FileInputStream(xmlFile);
1383: InputStreamReader isr = new InputStreamReader(fi, "UTF-8");
1384: BufferedReader buffr = new BufferedReader(isr);
1385: sb = new StringBuffer();
1386: int c = 0;
1387: while ((c = buffr.read()) != -1)
1388: {
1389: char ch = (char) c;
1390: sb.append(ch);
1391: // System.out.print((char)c);
1392: }
1393:
1394: }
1395: catch (Exception e)
1396: {
1397: e.printStackTrace();
1398: }
1399:
1400: boolean finished = false;
1401: // parse string and build document tree
1402: Xparse parser = new Xparse();
1403: parser.changeEntities = true;
1404: Node root = parser.parse(sb.toString());
1405: // printContents(root);
1406: Vector databases = new Vector();
1407: Vector tables = new Vector();
1408: Vector layouts = new Vector();
1409: Vector selects = new Vector();
1410: Vector creates = new Vector();
1411: Vector ids = new Vector();
1412: String delimiter = "|";
1413: int mode = -1;
1414: try
1415: {
1416: Node tempNode = root.find("convert/source", new int[]
1417: {1, 1});
1418: if (tempNode == null)
1419: throw new Error("parse error source tag missing");
1420: System.out.println(tempNode.name);
1421: int length = countNodes(tempNode);
1422: for (int i = 1; i <= length; i++)
1423: {
1424:
1425: DBBean database = new DBBean();
1426: tables = new Vector();
1427: layouts = new Vector();
1428: selects = new Vector();
1429: creates = new Vector();
1430: ids = new Vector();
1431: // parse dataBase
1432: Node node = root.find("convert/source/database/url", new int[]
1433: {1, 1, i, 1});
1434: Node node1 = root.find("convert/source/database/user", new int[]
1435: {1, 1, i, 1, 1});
1436: Node node2 = root.find("convert/source/database/password", new int[]
1437: {1, 1, i, 1, 1});
1438: Node node3 = root.find("convert/source/database", new int[]
1439: {1, 1, i});
1440: Node nodeMode = root.find("convert/source/database/mode", new int[]
1441: {1, 1, i, 1, 1});
1442: Node delimiterNode = root.find("convert/source/database/delimiter", new int[]
1443: {1, 1, i, 1, 1});
1444: Node useNormanToUnicodeMapper = root.find("convert/source/database/usenormantounicodemapper", new int[]
1445: {1, 1, i, 1, 1});
1446:
1447: if (delimiterNode != null)
1448: delimiter = delimiterNode.getCharacters();
1449: if (useNormanToUnicodeMapper != null)
1450: {
1451: database.setUseNormanToUnicodeMapper(Boolean.valueOf(useNormanToUnicodeMapper.getCharacters()).booleanValue());
1452: System.out.println("useMapper " + Boolean.valueOf(useNormanToUnicodeMapper.getCharacters().trim()).booleanValue());
1453: }
1454:
1455: if (node3 == null)
1456: throw new Error("parse error database tag missing");
1457: if (node == null)
1458: throw new Error("parse error url tag missing");
1459: if (node1 == null)
1460: throw new Error("parse error user tag missing");
1461: if (node2 == null)
1462: throw new Error("parse error password tag missing");
1463: String url = node.getCharacters();
1464: String user = node1.getCharacters();
1465: String password = node2.getCharacters();
1466: database.setURL(url.trim());
1467: database.setUserAndPasswd(user.trim(), password.trim());
1468: System.out.println(node.name + " " + node.getCharacters());
1469: System.out.println(node1.name + " " + node1.getCharacters());
1470: System.out.println(node2.name + " " + node2.getCharacters());
1471: String modeString = "";
1472: if (nodeMode == null)
1473: modeString = "convert";
1474: else
1475: modeString = nodeMode.getCharacters();
1476: if (modeString.equals("convert"))
1477: mode = DataBase.CONVERT_MODE;
1478: else if (modeString.equals("append"))
1479: mode = DataBase.APPEND_MODE;
1480: else if (modeString.equals("update"))
1481: mode = DataBase.UPDATE_MODE;
1482: else if (modeString.equals("delete"))
1483: mode = DataBase.DELETE_MODE;
1484:
1.82 rogo 1485: else if (modeString.equals("synchronize"))
1486: mode = DataBase.SYNCHRONIZE_MODE;
1487: // if(node3!=null)
1.79 rogo 1488: // System.out.println(node3.name);
1489:
1490: int length2 = countNodes(node3);
1491:
1492: System.out.println("number of tables " + length2);
1493:
1494: for (int j = 1; j <= length2; ++j)
1495: {
1496: Node node4 = root.find("convert/source/database/table", new int[]
1497: {1, 1, i, j});
1498: Node node5 = root.find("convert/source/database/table/select", new int[]
1499: {1, 1, i, j, 1});
1500: Node node6 = root.find("convert/source/database/table/create", new int[]
1501: {1, 1, i, j, 1});
1502: if (node4 != null)
1503: System.out.println(node4.name + " " + node4.attributes.get("layout").equals(""));
1504: if (node5 != null)
1505: System.out.println(node5.name + " " + node5.getCharacters());
1506: if (node6 != null)
1507: System.out.println(node6.name + " " + node6.getCharacters());
1508: if (node4 == null)
1509: throw new Error("parse error table tag missing");
1510: // if(node5==null) throw new Error("parse error select tag
1511: // missing");
1512: // if(node6==null) throw new Error("parse error create tag
1513: // missing");
1514: String name = (String) node4.attributes.get("name");
1515: String layout = (String) node4.attributes.get("layout");
1516: String id = (String) node4.attributes.get("id");
1517: System.out.println("id was " + id);
1518:
1519: if (name == null)
1520: throw new Error("parse error required table tag attribute name missing");
1521: if (layout == null)
1522: layout = "";
1523: if (id == null)
1524: id = "";
1525: if (name.equals(""))
1526: throw new Error("parse error table tag attribute must not be empty");
1527: tables.add(name);
1528: layouts.add(layout);
1529: ids.add(id);
1530: String query = (node5 == null) ? "" : node5.getCharacters();
1531: if (query.equals(""))
1532: System.err.println("Warning empty select tag or select tag missing !!");
1533: query = (query.equals("")) ? "select * from " + database.getQC() + name + database.getQC() : query;
1534: selects.add(query);
1535: if (node6 != null)
1536: creates.add(node6.getCharacters().trim());
1537: else
1538: creates.add("");
1539:
1540: }
1541: DataBase dataBase = new DataBase(database, tables, layouts, selects, creates, ids, mode);
1542: dataBase.delimiter = delimiter;
1543: databases.add(dataBase);
1544: }
1545: DBBean database = new DBBean();
1546: // parse dataBase
1547: Node node = root.find("convert/destination/database/url", new int[]
1548: {1, 1, 1, 1});
1549: Node node1 = root.find("convert/destination/database/user", new int[]
1550: {1, 1, 1, 1, 1});
1551: Node node2 = root.find("convert/destination/database/password", new int[]
1552: {1, 1, 1, 1, 1});
1553: String url = node.getCharacters();
1554: String user = node1.getCharacters();
1555: String password = node2.getCharacters();
1556: System.out.println(url);
1557: database.setURL(url.trim());
1558: database.setUserAndPasswd(user.trim(), password.trim());
1559: databases.add(new DataBase(database, null, null, null, null, null, 0));
1560: //databases.add(database);
1561: /*
1562: * for (Iterator iter = databases.iterator(); iter.hasNext();) { DataBase
1563: * db = (DataBase) iter.next();
1564: * convertBatch(db.bean,database,db.tables,db.layouts,db.selects,db.creates); }
1565: */
1566: // printContents(node3);
1567: // FM2SQL.fmInstance=new FM2SQL();
1568: }
1569: catch (Exception e)
1570: {
1571: // TODO Auto-generated catch block
1572: e.printStackTrace();
1573: }
1574: return databases;
1575: }
1576:
1577: private static int countNodes(Node tempNode)
1578: {
1579: int length = 0;
1580: for (int i = 0; i < tempNode.contents.v.size(); ++i)
1581: {
1582: Node node = (Node) tempNode.contents.v.elementAt(i);
1583: if (node.type.equals("element"))
1584: {
1585: if (node.name.equals("database"))
1586: length++;
1587: if (node.name.equals("table"))
1588: length++;
1589: }
1590:
1591: // System.out.println(((Node)tempNode.contents.v.elementAt(i)).attributes+"
1592: // "+i);
1593: }
1594: return length;
1595: }
1596:
1597: private static void printContents(Node root)
1598: {
1599:
1600: Vector contents = (root.index == null) ? root.contents.v : root.index.v;
1601: for (int i = 0; i < contents.size(); ++i)
1602: {
1603: Node n = (Node) contents.elementAt(i);
1604: if (n.type.equals("element"))
1605: {
1606: System.out.println("tag " + n.name);
1607: System.out.println(n.getCharacters());
1608: //contents=n.contents.v i=0;
1609: }
1610: // System.out.println(n.type);
1611: }
1612: }
1613:
1614: /**
1615: * reads the specified xml file
1616: *
1617: * @param xmlFile
1618: */
1619: public static void readXMLFile(String xmlFile)
1620: {
1621: try
1622: {
1623: InputStream stream = null;
1624:
1625: if (xmlFile.indexOf("file://") >= 0 || xmlFile.indexOf("http://") >= 0)
1626: {
1627: URL url = new URL(xmlFile);
1628: stream = url.openStream();
1629: }
1630: else
1631: // read XML Metadata from a file
1632: stream = new FileInputStream(xmlFile);
1633: InputStreamReader isr = new InputStreamReader(stream, "UTF-8");
1634: BufferedReader buffr = new BufferedReader(isr);
1635: StringBuffer sb = new StringBuffer();
1636: int c = 0;
1637: while ((c = buffr.read()) != -1)
1638: {
1639: char ch = (char) c;
1640: sb.append(ch);
1641: // System.out.print((char)c);
1642: }
1643: parseXMLConfig(sb);
1644: }
1645: catch (Exception e)
1646: {
1647: e.printStackTrace();
1648: }
1649: }
1650:
1651: /**
1652: * Helper class for Conversion etc Holds the some data
1653: *
1654: * @author rogo
1655: *
1656: */
1657:
1658: public static class ConversionProperties
1659: {
1660: String destTableName;
1661:
1662: String[] fieldNames;
1663:
1664: public ConversionProperties()
1665: {
1666: }
1667:
1668: public ConversionProperties(String destTableName, String[] fieldNames)
1669: {
1670: this.destTableName = destTableName;
1671: this.fieldNames = fieldNames;
1672:
1673: }
1674:
1675: }
1676:
1677: /**
1678: * Helper class for XML-File parsing Holds the parsed data
1679: *
1680: * @author rogo
1681: *
1682: */
1683: public static class DataBase
1684: {
1685: DBBean bean;
1686:
1687: Vector creates;
1688:
1689: Vector selects;
1690:
1691: Vector layouts;
1692:
1693: Vector tables;
1694:
1695: Vector ids;
1696:
1697: String delimiter = "//";
1698:
1699: /**
1700: * maps table name to index fields
1701: */
1702: Hashtable htIndex = new Hashtable();
1703:
1704: boolean useNormanToUnicodeMapper = false;
1705:
1706: final static int CONVERT_MODE = 1;
1707:
1708: final static int APPEND_MODE = 2;
1709:
1710: final static int UPDATE_MODE = 3;
1711:
1712: final static int DELETE_MODE = 4;
1713:
1714: final static int SYNCHRONIZE_MODE = 5;
1715:
1716: int mode = -1;
1717:
1718: public DataBase(DBBean bean, Vector tables, Vector layouts, Vector selects, Vector creates, Vector ids, int mode)
1719: {
1720: this.bean = bean;
1721: this.tables = tables;
1722: this.layouts = layouts;
1723: this.selects = selects;
1724: this.creates = creates;
1725: this.ids = ids;
1726: this.mode = mode;
1727: this.bean.setIDVector(ids);
1728: }
1729:
1730: /**
1731: * @param indexListVec
1732: */
1733: public void buildIndexTable(Vector indexListVec)
1734: {
1735: for (int i = 0; i < tables.size(); i++)
1736: {
1737: fillIndexList((String) tables.get(i), (String) indexListVec.get(i));
1738: }
1739: }
1740:
1741: /**
1742: * writes the data contained in this object to the buffered writer *
1743: *
1744: * @param buffr
1745: * @throws Exception
1746: */
1747: public void exportToXML(BufferedWriter buffr) throws Exception
1748: {
1749: // ids=bean.getIDVector();
1750: buffr.write(" <database>\n");
1751: buffr.write(" <url>" + bean.url + "</url>\n");
1752: buffr.write(" <user>" + bean.user + "</user>\n");
1753: buffr.write(" <password>" + bean.passwd + "</password>\n");
1754: buffr.write(" <delimiter>" + delimiter + "</delimiter>\n");
1755: String modeString = "";
1756: if (mode == CONVERT_MODE)
1757: modeString = "convert";
1758: else if (mode == APPEND_MODE)
1759: modeString = "append";
1760: else if (mode == UPDATE_MODE)
1761: modeString = "update";
1762: else if (mode == DELETE_MODE)
1763: modeString = "delete";
1.81 rogo 1764: else if (mode == SYNCHRONIZE_MODE)
1765: modeString = "synchronize";
1.79 rogo 1766:
1767: buffr.write(" <mode>" + modeString + "</mode>\n");
1768: buffr.write(" <usenormantounicodemapper>" + useNormanToUnicodeMapper + "</usenormantounicodemapper>\n");
1769:
1770: int index = 0;
1771: while (index < tables.size())
1772: {
1773: String table = (String) tables.get(index);
1774: String layout = (String) layouts.get(index);
1775: String select = (String) selects.get(index);
1776: String create = (String) creates.get(index);
1777: String id = (String) ids.get(index);
1778: IndexList indexList = (IndexList) htIndex.get(table);
1779: if (indexList == null)
1780: indexList = new IndexList();
1781: buffr.write(" <table name = \"" + table + "\" layout = \"" + layout + "\" id = \"" + id + "\" indexList =\"" + indexList + "\">\n");
1782: buffr.write(" <select>" + convertToEntities(select) + "</select>\n");
1783: if (!create.equals(""))
1784: buffr.write(" <create>" + create + " </create>\n");
1785: buffr.write(" </table>\n");
1786: index++;
1787: }
1788: buffr.write(" </database>\n");
1789: }
1790:
1791: public void fillIndexList(String table, String list)
1792: {
1793: IndexList indexList = new IndexList();
1794: StringTokenizer tokenizer = new StringTokenizer(list, ",");
1795: while (tokenizer.hasMoreTokens())
1796: {
1797: indexList.add(tokenizer.nextToken());
1798: }
1799: System.out.println(indexList);
1800:
1801: htIndex.put(table, indexList);
1802: }
1803:
1804: public String toString()
1805: {
1806: return bean.url + " " + tables;
1807: }
1808:
1809: }
1810:
1811: public static String convertToUTF8(Object command)
1812: {
1813: String str = null;
1814: try
1815: {
1816: str = new String(command.toString().getBytes("UTF-8"));
1817: }
1818: catch (UnsupportedEncodingException e)
1819: {
1820: // TODO Auto-generated catch block
1821: e.printStackTrace();
1822: }
1823: return str;
1824: }
1825:
1826: public static void writeConfig(String file, DataBase source, DataBase destination) throws Exception
1827: {
1828: if (!file.toLowerCase().endsWith(".xml"))
1829: file += ".xml";
1830: File f = new File(file);
1831:
1832: FileOutputStream fout = new FileOutputStream(f);
1833: OutputStreamWriter outsw = new OutputStreamWriter(fout, "UTF-8");
1834: BufferedWriter buffw = new BufferedWriter(outsw);
1835: buffw.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
1836: buffw.newLine();
1837: buffw.write("<convert>\n");
1838: buffw.write(" <source>\n");
1839: source.exportToXML(buffw);
1840: buffw.write(" </source>\n");
1841: buffw.write("\n <destination>\n");
1842: destination.exportToXML(buffw);
1843: buffw.write(" </destination>\n");
1844: buffw.write("</convert>\n");
1845: buffw.close();
1846: }
1847:
1848: public static void delete(String source, String destination, Vector names, Vector layouts, Vector selects, Vector creates, Vector ids, int mode) throws Exception
1849: {
1850: FM2SQL.ProgressDialog dialog = null;
1.83 ! rogo 1851: if (isGUI)
1.79 rogo 1852: {
1853: dialog = new FM2SQL.ProgressDialog(FM2SQL.fmInstance, bean);
1854: dialog.setTitle("Conversion running ...");
1855: dialog.title.setText("Getting table data ...");
1856: dialog.setLocation(FM2SQL.fmInstance.getLocationOnScreen().x + (FM2SQL.fmInstance.getWidth() - 400) / 2, FM2SQL.fmInstance.getLocationOnScreen().y + (FM2SQL.fmInstance.getHeight() - 250) / 2);
1857: dialog.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
1858: FM2SQL.fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
1859: dialog.thread = Thread.currentThread();
1860: }
1861: // setting user and passwd
1862: bean.setUserAndPasswd(user, passwd);
1863: // setting user and passwd
1864: beanDest.setUserAndPasswd(userDest, passwdDest);
1865: if (dialog != null)
1866: dialog.setSize(400, 250);
1867: StringBuffer command = null;
1868: String query = null;
1869: try
1870: {
1871: //bean.setConnection("jdbc:fmpro:http://141.14.237.74:8050");
1872: //bean.setConnection("jdbc:postgresql://erebos/test","postgres","rogo");
1873: bean.setConnection(source);
1874: if (names == null)
1875: names = bean.getTableNames();
1876: // Collections.sort(names);
1877: int tbIndex = 1;
1878:
1879: // System.out.println("Start at
1880: // "+names.indexOf("archimedes_facsimiles"));
1881: for (tbIndex = 0; tbIndex < names.size(); ++tbIndex)
1882: {
1883: Vector[] result = null;
1884: java.util.TreeSet myIds = new TreeSet();
1885: java.util.TreeSet myIdsDest = new TreeSet();
1886: int deltaID = 1;
1887: String idField = "";
1888: String destTableName = "";
1889:
1890: try
1891: {
1892: query = "select * from " + bean.getQC() + names.get(tbIndex).toString() + bean.getQC();
1893: String layout = (layouts.isEmpty()) ? "" : layouts.get(tbIndex).toString();
1894: query = (selects != null) ? selects.get(tbIndex).toString() : query;
1895: //if vectors[1].get(i) != null)
1896: if (layout != "")
1897: {
1898: layout = " layout " + bean.getQC() + layout + bean.getQC();
1899: String name = names.get(tbIndex).toString();
1900: StringBuffer queryLayout = new StringBuffer(query);
1901: queryLayout.insert(queryLayout.indexOf(name) + name.length() + 1, " " + layout);
1902: query = queryLayout.toString();
1903: System.out.println("added layout " + query);
1904:
1905: }
1906: dialog.title.setText("Getting table data ...");
1907: dialog.table.setText(names.get(tbIndex).toString());
1908: dialog.status.setText("Table " + (tbIndex + 1) + " of " + names.size());
1909: dialog.show();
1910: bean.getConnection();
1911: bean.makeQuery(query, 50);
1912: idField = ids.get(tbIndex).toString();
1913:
1914: }
1915: catch (Exception e)
1916: {
1917: continue;
1918: }
1919: // determine destTableName from createStatement or from source
1920: // table name
1921: if (!creates.get(tbIndex).equals(""))
1922: {
1923: String create = creates.get(tbIndex).toString().toLowerCase();
1924: int fromIndex = create.indexOf("table") + 5;
1925: int toIndex = create.indexOf("(");
1926: destTableName = create.substring(fromIndex, toIndex).replaceAll(beanDest.getQC(), "").trim();
1927: System.out.println("destTable " + destTableName);
1928:
1929: }
1930: else
1931: destTableName = convertText(names.get(tbIndex).toString());
1932:
1933: // for id kram
1934: Vector vec = null;
1935: Vector vecDest = null;
1936: // tempo
1937: beanDest.setConnection(destination);
1938: int rowCount = (idField != "") ? myIds.size() : bean.getRowCount(query);
1939: String tempID = bean.getQC() + idField + bean.getQC();
1940: String tempIDdest = beanDest.getQC() + convertText(idField) + beanDest.getQC();
1941:
1942: int endIndex = -1;
1943: String tempQuery = query;
1944: String destQuery = query.replaceAll(names.get(tbIndex).toString(), destTableName);
1945: String tempQueryDest = destQuery;
1946: // remove extra query parts
1947: // destQuery.substring(0,destQuery.lastIndexOf(destTableName)+destTableName.length()+1);
1948: System.out.println("new Query " + tempQueryDest);
1949: if (!idField.equals(""))
1950: {
1951: long startTime = System.currentTimeMillis();
1952: int counter = -1;
1953: while (true)
1954: {
1955: ++counter;
1956: if (counter == 0 && dialog != null)
1957: dialog.title.setText("Check if data is available");
1958: else if (dialog != null)
1959: dialog.title.setText("Check if more data is available");
1960: myIds = bean.getIDVector(ids.get(tbIndex).toString(), (String) names.get(tbIndex), tempQuery, numHits);
1961: myIdsDest = beanDest.getIDVector(convertText(idField), destTableName, tempQueryDest, numHits);
1962: if (myIds.isEmpty())
1963: break;
1964: vec = new Vector(myIds);
1965: vecDest = new Vector(myIdsDest);
1966: rowCount = vec.size();
1967: // Deletion will work this way
1968: Vector deleted = new Vector(vec);
1969: Vector linesToDelete = new Vector(vecDest);
1970: // remove all lines that should not be deleted
1971: linesToDelete.removeAll(deleted);
1972: // System.out.println("ID LIST SIZE " +
1973: // Math.round((double) myIds.size() / (double)
1974: // numIntervalls) + " " + myIdsDest.size());
1975: /// @TODO complete delete task remove query show lines
1976: // to be deleted let user choose if he wants that
1977: System.out.println("number of lines to be deleted " + linesToDelete.size());
1978: deltaID = (int) Math.round((double) myIds.size() / (double) numIntervalls);
1979: beanDest.setConnection(destination);
1980:
1981: Statement stm = beanDest.getConnection().createStatement();
1982:
1983: Vector tables = beanDest.getTableNames();
1984: // Collections.sort(tables);
1985: System.out.println(names.get(tbIndex) + " " + tables.indexOf(convertText((String) names.get(tbIndex)))); // "//beanDest.getTypeNames());
1986: tables = beanDest.getTableNames();
1987: // System.out.println(beanDest.getTableNames(beanDest.getCatalogs().get(2).toString()));
1988: stm = beanDest.getConnection().createStatement();
1989:
1990: if (dialog != null)
1991: dialog.title.setText(" Deleting table data ...");
1992:
1993: int j = -1;
1994:
1995: Vector row = null;
1996: command = new StringBuffer();
1997:
1998: command.append("DELETE FROM");
1999: command.append(beanDest.getQC());
2000: command.append(destTableName);
2001: //command.append(convertText((String)
2002: // names.get(tbIndex)));
2003: command.append(beanDest.getQC());
2004: int size = bean.getColumnNames().size();
2005: command.append("WHERE " + convertText(ids.get(tbIndex).toString()) + " = ?");
2006: PreparedStatement pstm = beanDest.getConnection().prepareStatement(command.toString());
2007: System.out.println(command + " " + tbIndex);
2008: //int rowCount = bean.getRowCount(query);
2009: // int idIndex =
2010: // bean.getColumnNames().indexOf(ids.get(tbIndex));
2011: while (true)
2012: {
2013:
2014: ++j;
2015: if (j == linesToDelete.size())
2016: break;
2017: //print rows
2018: pstm.setString(1, linesToDelete.get(j).toString());
2019: System.out.println(pstm.toString());
2020: pstm.execute();
2021: if (dialog != null)
2022: dialog.progress.setValue((int) (((double) (j + 1) / (double) rowCount) * 100.0));
2023: command = null;
2024: }
2025: // prepare new query for next chunk
2026: if (query.indexOf("where") > 0)
2027: tempQuery = query + " and " + tempID + ">'" + vec.lastElement() + "'";
2028: else
2029: tempQuery = query + " where " + tempID + ">'" + vec.lastElement() + "'";
2030:
2031: } //to outer while
2032: } // to idfield if
2033: } // table loop
2034:
2035: }
2036: catch (Exception e)
2037: {
2038: System.out.println("Error while connecting to database " + e);
2039: if (dialog != null)
2040: {
2041: dialog.setVisible(false);
2042: dialog.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
2043: FM2SQL.fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
2044: }
2045: java.io.ByteArrayOutputStream b = new java.io.ByteArrayOutputStream();
2046: java.io.PrintStream stream = new java.io.PrintStream(b);
2047: stream.print(command + "\n\n");
2048: e.printStackTrace(stream);
2049: FM2SQL.showErrorDialog(b.toString(), "Error occured !");
2050:
2051: }
2052: if (dialog != null)
2053: {
2054: dialog.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
2055: FM2SQL.fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
2056:
2057: dialog.setVisible(false);
2058: }
2059: } // to method
2060:
2061: /**
2062: * synchronize method based on delete method code
2063: *
2064: * @param source
2065: * @param destination
2066: * @param names
2067: * @param layouts
2068: * @param selects
2069: * @param creates
2070: * @param ids
2071: * @param mode
2072: * @throws Exception
2073: */
2074: // TODO implement append,update and delete in one method
2075: // TODO using id based algorithm
2076: public static void synchronize(String source, String destination, Vector names, Vector layouts, Vector selects, Vector creates, Vector ids, int mode, String delimiter, Vector indexList)
2077: throws Exception
2078: {
2079: System.out.println(" bin in synchronize!!!");
2080: FM2SQL.ProgressDialog dialog = null;
1.83 ! rogo 2081: if (isGUI)
1.79 rogo 2082: {
2083: dialog = new FM2SQL.ProgressDialog(FM2SQL.fmInstance, bean);
2084: dialog.setTitle("Synchronize running ...");
2085: dialog.title.setText("Getting table data ...");
2086: dialog.setLocation(FM2SQL.fmInstance.getLocationOnScreen().x + (FM2SQL.fmInstance.getWidth() - 400) / 2, FM2SQL.fmInstance.getLocationOnScreen().y + (FM2SQL.fmInstance.getHeight() - 250) / 2);
2087: dialog.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
2088: FM2SQL.fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
2089: dialog.thread = Thread.currentThread();
2090: }
2091: // setting user and passwd
2092: bean.setUserAndPasswd(user, passwd);
2093: // setting user and passwd
2094: beanDest.setUserAndPasswd(userDest, passwdDest);
2095: if (dialog != null)
2096: dialog.setSize(400, 250);
2097: StringBuffer command = null;
2098: String query = null;
2099: try
2100: {
2101: //bean.setConnection("jdbc:fmpro:http://141.14.237.74:8050");
2102: //bean.setConnection("jdbc:postgresql://erebos/test","postgres","rogo");
2103: bean.setConnection(source);
2104: if (names == null)
2105: names = bean.getTableNames();
2106: // Collections.sort(names);
2107: int tbIndex = 1;
2108:
2109: // System.out.println("Start at
2110: // "+names.indexOf("archimedes_facsimiles"));
2111: for (tbIndex = 0; tbIndex < names.size(); ++tbIndex)
2112: {
2113: Vector[] result = null;
2114: java.util.TreeSet myIds = new TreeSet();
2115: java.util.TreeSet myIdsDest = new TreeSet();
2116: int deltaID = 1;
2117: String idField = "";
2118: String destTableName = "";
2119:
2120: try
2121: {
2122: query = "select * from " + bean.getQC() + names.get(tbIndex).toString() + bean.getQC();
2123: String layout = (layouts.isEmpty()) ? "" : layouts.get(tbIndex).toString();
2124: query = (selects != null) ? selects.get(tbIndex).toString() : query;
2125: //if vectors[1].get(i) != null)
2126: if (!layout.equals(""))
2127: {
2128: layout = " layout " + bean.getQC() + layout + bean.getQC();
2129: String name = names.get(tbIndex).toString();
2130: StringBuffer queryLayout = new StringBuffer(query);
2131: queryLayout.insert(queryLayout.indexOf(name) + name.length() + 1, " " + layout);
2132: query = queryLayout.toString();
2133: System.out.println("added layout " + query);
2134:
2135: }
2136: if (dialog != null)
2137: {
2138: dialog.title.setText("Getting table data ...");
2139: dialog.table.setText(names.get(tbIndex).toString());
2140: dialog.status.setText("Table " + (tbIndex + 1) + " of " + names.size());
2141: dialog.show();
2142: }
2143: bean.getConnection();
2144: bean.makeQuery(query, 50);
2145: idField = ids.get(tbIndex).toString();
2146:
2147: }
2148: catch (Exception e)
2149: {
2150: continue;
2151: }
2152: // determine destTableName from createStatement or from source
2153: // table name
2154: if (!creates.get(tbIndex).equals(""))
2155: {
2156: String create = creates.get(tbIndex).toString().toLowerCase();
2157: int fromIndex = create.indexOf("table") + 5;
2158: int toIndex = create.indexOf("(");
2159: destTableName = create.substring(fromIndex, toIndex).replaceAll(beanDest.getQC(), "").trim();
2160: System.out.println("destTable " + destTableName);
2161:
2162: }
2163: else
2164: destTableName = convertText(names.get(tbIndex).toString());
2165:
2166: // for id kram
2167: Vector vec = null;
2168: Vector vecDest = null;
2169: // tempo
2170: beanDest.setConnection(destination);
2171: int rowCount = (idField != "") ? myIds.size() : bean.getRowCount(query);
2172: String tempID = bean.getQC() + idField + bean.getQC();
2173: String tempIDdest = beanDest.getQC() + convertText(idField) + beanDest.getQC();
2174:
2175: int endIndex = -1;
2176: String tempQuery = query;
2177: String destQuery = query.replaceAll(names.get(tbIndex).toString(), destTableName);
2178: destQuery = destQuery.replaceAll(bean.getQC(), beanDest.getQC());
2179: destQuery = removeLayoutPartFromQuery(destQuery, layouts.get(tbIndex).toString());
2180: // TODO remove layout part for destQuery
2181: String tempQueryDest = destQuery;
2182: // remove extra query parts
2183: // destQuery.substring(0,destQuery.lastIndexOf(destTableName)+destTableName.length()+1);
2184: System.out.println("new Query " + tempQueryDest);
2185: System.out.println("idfield " + idField + " " + ids.get(tbIndex).toString());
2186: if (!idField.equals(""))
2187: {
2188: long startTime = System.currentTimeMillis();
2189: int counter = -1;
2190: TreeSet linesToDelete = null;
2191: PreparedStatement delPSt = null;
2192: while (true)
2193: {
2194: ++counter;
2195: if (counter == 0 && dialog != null)
2196: dialog.title.setText("Check if data is available");
2197: else if (dialog != null)
2198: dialog.title.setText("Check if more data is available");
2199:
2200: myIds = bean.getIDVector(ids.get(tbIndex).toString(), (String) names.get(tbIndex), tempQuery, 0);
2201: myIdsDest = beanDest.getIDVector(convertText(idField), destTableName, tempQueryDest, 0);
2202: //System.out.println("status of remove
2203: // "+myIds.remove("b015892"));
2204: System.out.println("ids found for " + idField + " " + !myIds.isEmpty());
2205: if (myIds.isEmpty())
2206: break;
2207: vec = new Vector(myIds);
2208: vecDest = new Vector(myIdsDest);
2209: rowCount = vec.size();
2210: // Deletion will work this way
2211: Vector deleted = new Vector(vec);
2212:
2213: TreeSet linesToAppend = new TreeSet(vec);
2214: linesToAppend.addAll(vec);
2215: linesToDelete = new TreeSet(vecDest);
2216: // remove all lines that are already in dest database
2217: linesToAppend.removeAll(vecDest);
2218: // remove all lines that should not be deleted
2219: linesToDelete.removeAll(deleted);
2220: System.out.println("linesToAppend " + linesToAppend.size() + " " + destTableName);
2221: System.out.println("linesToDelete " + linesToDelete.size() + " " + destTableName);
2222: System.out.println("ID LIST SIZE " + Math.round((double) myIds.size() / (double) numIntervalls) + " " + myIds.size());
2223: deltaID = (int) Math.round((double) myIds.size() / (double) numIntervalls);
2224: ConversionProperties prop = getFieldNamesAndDestTableName(creates.get(tbIndex).toString(), query, names.get(tbIndex).toString());
2225: StringBuffer insCommand = createInsertCommand(prop.destTableName, prop.fieldNames);
2226: StringBuffer updCommand = createUpdateCommand(prop.destTableName, prop.fieldNames, tempIDdest);
2227: StringBuffer delCommand = createDeleteCommand(destTableName, tempIDdest);
2228: PreparedStatement insPst = beanDest.getConnection().prepareStatement(insCommand.toString());
2229: PreparedStatement updPst = beanDest.getConnection().prepareStatement(updCommand.toString());
2230: delPSt = beanDest.getConnection().prepareStatement(delCommand.toString());
2231: // delPSt.setString(1,"b015892");
2232: // delPSt.execute();
2233: // if (true)
2234: // return;
2235: if (vec.size() <= numIntervalls)
2236: {
2237: endIndex = 0;
2238: deltaID = vec.size();
2239: }
2240: for (int k = 0; k < vec.size() - deltaID; k = k + deltaID)
2241: {
2242: System.out.println(vec.get(k) + " " + vec.get(k + deltaID) + " " + vec.lastElement());
2243: if (query.indexOf("where") > 0)
2244: tempQuery = query + " and " + tempID + ">='" + vec.get(k) + "' and " + tempID + "<='" + vec.get(k + deltaID) + "'";
2245: else
2246: tempQuery = query + " where " + tempID + ">='" + vec.get(k) + "' and " + tempID + "<='" + vec.get(k + deltaID) + "'";
2247: System.out.println(tempQuery);
2248: if (dialog != null)
2249: dialog.title.setText("Reading table data ...");
2250:
2251: // bean.makeQuery(tempQuery, deltaID);
2252: if (dialog != null)
2253: dialog.title.setText("Writing table data ...");
2254:
1.82 rogo 2255: performSynchronize(idField, vec, tempQuery, linesToDelete, linesToAppend, insPst, updPst, delPSt, deltaID, delimiter, dialog);
1.79 rogo 2256: // System.out.println("ID LIST SIZE " +
2257: // Math.round((double) myIds.size() / (double)
2258: // numIntervalls) + " " + myIdsDest.size());
2259: endIndex = k + deltaID;
2260: }
2261: System.out.println(endIndex);
2262: //all data written ? if not write last chunk of data
2263: if (endIndex == vec.size() - 1)
2264: System.out.println("fits");
2265: else
2266: {
2267: System.out.println(" last intervall from " + vec.get(endIndex) + " " + vec.lastElement());
2268:
2269: if (query.indexOf("where") > 0)
2270: tempQuery = query + " and " + tempID + ">='" + vec.get(endIndex) + "' and " + tempID + "<='" + vec.lastElement() + "'";
2271: else
2272: tempQuery = query + " where " + tempID + ">='" + vec.get(endIndex) + "' and " + tempID + "<='" + vec.lastElement() + "'";
2273: System.out.println(tempQuery);
2274: if (dialog != null)
2275: dialog.title.setText("Reading table data ...");
2276: // bean.makeQuery(tempQuery, 0);
2277: if (dialog != null)
2278: dialog.title.setText("Writing table data ...");
1.82 rogo 2279: performSynchronize(idField, vec, tempQuery, linesToDelete, linesToAppend, insPst, updPst, delPSt, deltaID, delimiter, dialog);
1.79 rogo 2280: // System.out.println("ID LIST SIZE " +
2281: // Math.round((double) myIds.size() / (double)
2282: // numIntervalls) + " " + myIdsDest.size());
2283: }
2284: // prepare new query for next chunk
2285: if (query.indexOf("where") > 0)
2286: tempQuery = query + " and " + tempID + ">'" + vec.lastElement() + "'";
2287: else
2288: tempQuery = query + " where " + tempID + ">'" + vec.lastElement() + "'";
2289:
2290: }
2291: String tableName = names.get(tbIndex).toString();
1.82 rogo 2292: if (indexList.isEmpty())
1.79 rogo 2293: {
1.82 rogo 2294: IndexList idList = (IndexList) indexList.get(0);
2295: System.out.println("found list " + idList);
2296: Statement stm = beanDest.getConnection().createStatement();
2297: Vector destTables = beanDest.getTableNames();
2298: System.out.println("tempQueryDest" + tempQueryDest);
2299: beanDest.makeQuery(tempQueryDest, 0);
2300: for (Iterator iter = idList.iterator(); iter.hasNext();)
1.79 rogo 2301: {
1.82 rogo 2302: String indexField = (String) iter.next();
2303: indexField = convertText(indexField);
2304: String indexName = destTableName + "_" + indexField;
2305: if (destTables.contains(indexName))
2306: {
2307: stm.execute("DROP INDEX " + destTableName + "_" + indexField);
2308: // continue;
2309: }
2310: // stm.execute("DROP INDEX
2311: // "+destTableName+"_"+indexField);
1.79 rogo 2312:
1.82 rogo 2313: String type = beanDest.getColumnType(indexField).toLowerCase();
2314: // System.out.println(indexField+" "+type+"
2315: // "+(type.indexOf("text") >= 0 ||
2316: // type.indexOf("varchar") >= 0 || type.indexOf("char")
2317: // >= 0));
2318: if (type.indexOf("text") >= 0 || type.indexOf("varchar") >= 0 || type.indexOf("char") >= 0)
1.79 rogo 2319: {
1.82 rogo 2320: if (beanDest.url.indexOf("mysql") >= 0)
2321: {
2322: //System.out.println("CREATE INDEX " +
2323: // indexName + " ON " + destTableName + " (" +
2324: // indexField + "(10))");
2325: // TODO problem if index exist !!!
2326: stm.execute("CREATE INDEX " + indexName + " ON " + destTableName + " (" + indexField + "(10))");
2327: }
2328: else
2329: {
2330: stm.execute("CREATE INDEX " + indexName + " ON " + destTableName + " (lower( " + indexField + "))");
2331:
2332: }
2333:
1.79 rogo 2334: }
2335: else
2336: {
1.82 rogo 2337: stm.execute("CREATE INDEX " + destTableName + "_" + indexField + " ON " + destTableName + "(" + indexField + ")");
1.79 rogo 2338:
2339: }
2340:
1.82 rogo 2341: // stm.execute("DROP INDEX
2342: // "+destTableName+"_"+indexField);
1.79 rogo 2343:
2344: }
2345: }
2346: // CREATE UNIQUE INDEX title_idx ON films (title);
2347: for (Iterator iter = linesToDelete.iterator(); iter.hasNext();)
2348: {
2349: String id = (String) iter.next();
2350: delPSt.setString(1, id);
2351: delPSt.execute();
2352:
2353: }
2354:
2355: long endTime = System.currentTimeMillis();
2356: System.out.println("Time for incremental synchronize elapsed " + (endTime - startTime));
2357: } // to idfield if
2358: } // table loop
2359:
2360: }
2361: catch (Exception e)
2362: {
2363: System.out.println("Error while connecting to database " + e);
2364: e.printStackTrace();
2365: if (dialog != null)
2366: {
2367: dialog.setVisible(false);
2368: dialog.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
2369: FM2SQL.fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
2370: }
2371: java.io.ByteArrayOutputStream b = new java.io.ByteArrayOutputStream();
2372: java.io.PrintStream stream = new java.io.PrintStream(b);
2373: stream.print(command + "\n\n");
2374: e.printStackTrace(stream);
1.83 ! rogo 2375: if(dialog != null)
1.79 rogo 2376: FM2SQL.showErrorDialog(b.toString(), "Error occured !");
2377:
2378: }
2379: if (dialog != null)
2380: {
2381: dialog.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
2382: FM2SQL.fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
2383:
2384: dialog.setVisible(false);
2385: }
2386: }
2387:
2388: /**
2389: * @param destQuery
2390: * @param string
2391: * @return
2392: */
2393: private static String removeLayoutPartFromQuery(String destQuery, String layoutName)
2394: {
2395: String removeString = "layout " + beanDest.getQC() + layoutName + beanDest.getQC();
2396: destQuery = destQuery.replaceFirst(removeString, "");
2397: System.out.println("destQuery change to " + destQuery);
2398: return destQuery;
2399: }
2400:
2401: private static void performSynchronize(String idField, Vector vec, String tempQuery, TreeSet linesToDelete, TreeSet linesToAppend, PreparedStatement insPst, PreparedStatement updPst,
1.82 rogo 2402: PreparedStatement delPSt, int deltaID, String delimiter, FM2SQL.ProgressDialog dialog) throws SQLException, ParseException
1.79 rogo 2403: {
1.82 rogo 2404: if (dialog != null)
2405: {
2406: dialog.progress.setValue(0);
2407: dialog.title.setText("Retrieving new data");
2408: }
2409:
1.79 rogo 2410: Vector[] vectors = bean.getQueryData(tempQuery, deltaID);
1.82 rogo 2411: int count = 0, size = vectors[0].size();
1.79 rogo 2412: int idIndex = vectors[1].indexOf(idField);
1.82 rogo 2413: //System.out.println(idIndex + " " + vectors[1] + " " + idField);
1.79 rogo 2414: // todo arraylist code has to be added
1.82 rogo 2415: if (dialog != null)
2416: dialog.title.setText("Synchronize with new data");
2417:
1.79 rogo 2418: for (Iterator iter = vectors[0].iterator(); iter.hasNext();)
2419: {
2420: Vector line = (Vector) iter.next();
2421: Object lineIDIndex = line.get(idIndex);
2422: if (linesToAppend.contains(lineIDIndex))
2423: System.out.println("line " + linesToAppend.contains(line.get(idIndex)) + " " + lineIDIndex);
2424: if (linesToAppend.contains(lineIDIndex))
2425: {
2426: for (int l = 0; l < line.size(); ++l)
2427: {
2428: Object obj = line.get(l);
2429: if (obj instanceof ArrayList)
2430: obj = formatFileMakerArray((List) obj, delimiter);
2431: if (obj != null)
2432: insPst.setString(l + 1, obj.toString());
2433: else
2434: insPst.setNull(l + 1, Types.NULL);
2435: }
2436: insPst.execute();
2437:
2438: }
2439: else
2440: // update
2441: {
2442: for (int l = 0; l < line.size(); ++l)
2443: {
2444: Object obj = line.get(l);
2445: if (obj instanceof ArrayList)
2446: obj = formatFileMakerArray((List) obj, delimiter);
2447: if (obj != null)
2448: updPst.setString(l + 1, obj.toString());
2449: else
2450: updPst.setNull(l + 1, Types.NULL);
2451: }
2452: updPst.setString(line.size() + 1, line.get(idIndex).toString());
2453: //updPst.addBatch();
1.82 rogo 2454: //updPst.execute();
2455: }
2456: if (dialog != null)
2457: {
2458: int value = (int) Math.round(((double) count / (double) size) * 100.0);
2459: dialog.progress.setValue(value);
2460: count++;
1.79 rogo 2461: }
2462: }
2463: //updPst.executeBatch();
2464: } // to method
2465:
2466: /**
2467: * Converts input String in norman encoding to unicode
2468: *
2469: * @param inp
2470: * @return converted String
2471: */
2472: static public String normanToUnicode(String inp)
2473: {
2474: StringBuffer buf = new StringBuffer();
2475: for (int i = 0; i < inp.length(); i++)
2476: {
2477: char c = inp.charAt(i);
2478: // System.out.println("char "+c+" "+(int)c);
2479: switch (c)
2480: {
2481: case 1 :
2482: buf.append("\u00d0");
2483: break; // Eth
2484: case 2 :
2485: buf.append("\u00f0");
2486: break; // eth
2487: case 3 :
2488: buf.append("\u0141");
2489: break; // Lslash
2490: case 4 :
2491: buf.append("\u0142");
2492: break; // lslash
2493: case 5 :
2494: buf.append("\u0160");
2495: break; // S caron
2496: case 6 :
2497: buf.append("\u0161");
2498: break; // s caron
2499: case 7 :
2500: buf.append("\u00dd");
2501: break; // Y acute
2502: case 8 :
2503: buf.append("\u00fd");
2504: break; // y acute
2505: case 11 :
2506: buf.append("\u00de");
2507: break; // Thorn
2508: case 12 :
2509: buf.append("\u00fe");
2510: break; // thorn
2511: case 14 :
2512: buf.append("\u017d");
2513: break; // Z caron
2514: case 15 :
2515: buf.append("\u017e");
2516: break; // z caron
2517: case 17 :
2518: buf.append("\u0073");
2519: break; // asciitilde
2520: case 18 :
2521: buf.append("j\u0305");
2522: break; // j macron [does a single char exist?]
2523: case 19 :
2524: buf.append("^");
2525: break; // circumflex
2526: case 20 :
2527: buf.append("\u0303");
2528: break; // tilde
2529: case 21 :
2530: buf.append("\u00bd");
2531: break; // onehalf
2532: case 22 :
2533: buf.append("\u00bc");
2534: break; // onequarter
2535: case 23 :
2536: buf.append("\u00b9");
2537: break; // onesuperior
2538: case 24 :
2539: buf.append("\u00be");
2540: break; // threequarters
2541: case 25 :
2542: buf.append("\u00b3");
2543: break; // threesuperior
2544: case 26 :
2545: buf.append("\u00b2");
2546: break; // twosuperior
2547: case 27 :
2548: buf.append("\u00a6");
2549: break; // brokenbar
2550: case 28 :
2551: buf.append("-");
2552: break; // minus
2553: case 29 :
2554: buf.append("\u00d7");
2555: break; // multiply
2556: case 39 :
2557: buf.append("'");
2558: break; // quotesingle
2559: case 94 :
2560: buf.append("\u0302");
2561: break; // circumflex
2562: case 96 :
2563: buf.append("\u0300");
2564: break; // grave
2565: case 196 :
2566: buf.append("\u00c4");
2567: break; // A dieresis
2568: case 197 :
2569: buf.append("\u00c5");
2570: break; // A ring
2571: case 201 :
2572: buf.append("\u00c9");
2573: break; // E acute
2574: case 209 :
2575: buf.append("\u00d1");
2576: break; // N tilde
2577: case 214 :
2578: buf.append("\u00d6");
2579: break; // O dieresis
2580: case 220 :
2581: buf.append("\u00dc");
2582: break; // U dieresis
2583: case 225 :
2584: buf.append("\u00e1");
2585: break; // a acute
2586: case 224 :
2587: buf.append("\u00e0");
2588: break; // a grave
2589: case 226 :
2590: buf.append("\u00e2");
2591: break; // a circumflex
2592: case 228 :
2593: buf.append("\u00e4");
2594: break; // a dieresis
2595: case 227 :
2596: buf.append("\u00e3");
2597: break; // a tilde
2598: case 229 :
2599: buf.append("\u0101");
2600: break; // a macron
2601: case 231 :
2602: buf.append("\u00e7");
2603: break; // c cedilla
2604: case 233 :
2605: buf.append("\u00e9");
2606: break; // e acute
2607: case 232 :
2608: buf.append("\u00e8");
2609: break; // e grave
2610: case 234 :
2611: buf.append("\u00ea");
2612: break; // e circumflex
2613: case 235 :
2614: buf.append("\u00eb");
2615: break; // e dieresis
2616: case 237 :
2617: buf.append("\u00ed");
2618: break; // i acute
2619: case 236 :
2620: buf.append("\u00ec");
2621: break; // i grave
2622: case 238 :
2623: buf.append("\u00ee");
2624: break; // i circumflex
2625: case 239 :
2626: buf.append("\u00ef");
2627: break; // i dieresis
2628: case 241 :
2629: buf.append("\u00f1");
2630: break; // n tilde
2631: case 243 :
2632: buf.append("\u00f3");
2633: break; // o acute
2634: case 242 :
2635: buf.append("\u00f2");
2636: break; // o grave
2637: case 244 :
2638: buf.append("\u00f4");
2639: break; // o circumflex
2640: case 246 :
2641: buf.append("\u00f6");
2642: break; // o dieresis
2643: case 245 :
2644: buf.append("\u00f5");
2645: break; // o tilde
2646: case 250 :
2647: buf.append("\u00fa");
2648: break; // u acute
2649: case 249 :
2650: buf.append("\u00f9");
2651: break; // u grave
2652: case 251 :
2653: buf.append("\u00fb");
2654: break; // u circumflex
2655: case 252 :
2656: buf.append("\u00fc");
2657: break; // u dieresis
2658: case 8224 :
2659: buf.append("\u1e6d");
2660: break; // t underdot
2661: case 176 :
2662: buf.append("\u00b0");
2663: break; // degree
2664: case 162 :
2665: buf.append("\u1ebd");
2666: break; // e tilde
2667: case 163 :
2668: buf.append("\u00a3");
2669: break; // sterling
2670: case 167 :
2671: buf.append("\u00a7");
2672: break; // section
2673: case 182 :
2674: buf.append("\u00b6");
2675: break; // paragraph
2676: case 223 :
2677: buf.append("\u015b");
2678: break; // s acute
2679: case 174 :
2680: buf.append("\u1e5b");
2681: break; // r underdot
2682: case 169 :
2683: buf.append("\u1e45");
2684: break; // n overdot
2685: case 353 :
2686: buf.append("\u1e45");
2687: break; // n overdot
2688: case 180 :
2689: buf.append("\u0301");
2690: break; // acute
2691: case 168 :
2692: buf.append("\u0308");
2693: break; // dieresis
2694: case 8800 :
2695: buf.append("\u1e6d");
2696: break; // t underdot
2697: case 198 :
2698: buf.append("\u00c6");
2699: break; // AE
2700: case 216 :
2701: buf.append("\u014d");
2702: break; // o macron
2703: case 8734 :
2704: buf.append("\u0129");
2705: break; // i tilde
2706: case 177 :
2707: buf.append("\u00b1");
2708: break; // plusminus
2709: case 165 :
2710: buf.append("\u012b");
2711: break; // i macron
2712: case 181 :
2713: buf.append("\u1e43");
2714: break; // m underdot
2715: case 8706 :
2716: buf.append("\u1e0d");
2717: break; // d underdot
2718: case 240 :
2719: buf.append("\u1e0d");
2720: break; // d underdot
2721:
2722: case 8721 :
2723: buf.append("\u1e63");
2724: break; // s underdot
2725: case 960 :
2726: buf.append("\u017a");
2727: break; // z acute
2728: case 8747 :
2729: buf.append("\u1e45");
2730: break; // n overdot
2731: case 937 :
2732: buf.append("\u0169");
2733: break; // u tilde
2734: case 230 :
2735: buf.append("\u00e6");
2736: break; // ae
2737: case 248 :
2738: buf.append("\u00f8");
2739: break; // oslash
2740: case 191 :
2741: buf.append("\u0304\u0306");
2742: break; // macron breve
2743: case 172 :
2744: buf.append("\u1e37");
2745: break; //
2746: case 8730 :
2747: buf.append("j\u0305");
2748: break; // j macron [does a single char exist?]
2749: case 402 :
2750: buf.append("\u0103");
2751: break; // a breve
2752: case 8776 :
2753: buf.append("\u016d");
2754: break; // u breve
2755: case 187 :
2756: buf.append("\u1e42");
2757: break; // M underdot
2758: case 8230 :
2759: buf.append("\u2026");
2760: break; // ellipsis
2761: case 192 :
2762: buf.append("\u00c0");
2763: break; // A grave
2764: case 195 :
2765: buf.append("\u00c3");
2766: break; // A tilde
2767: case 213 :
2768: buf.append("\u00d5");
2769: break; // O tilde
2770: case 338 :
2771: buf.append("m\u0306");
2772: break; // m breve
2773: case 339 :
2774: buf.append("\u0153");
2775: break; // oe
2776: case 8211 :
2777: buf.append("\u2013");
2778: break; // endash
2779: case 8212 :
2780: buf.append("\u2014");
2781: break; // emdash
2782: case 8220 :
2783: buf.append("\u201c");
2784: break; // quotedblleft
2785: case 8221 :
2786: buf.append("\u201d");
2787: break; // quotedblright
2788: case 8216 :
2789: buf.append("\u2018");
2790: break; // quoteleft
2791: case 8217 :
2792: buf.append("\u2019");
2793: break; // quoteright
2794: case 247 :
2795: buf.append("\u1e37");
2796: break; // l underring [actually underdot]
2797: case 9674 :
2798: buf.append("\u1e41");
2799: break; // m overdot
2800: case 255 :
2801: buf.append("n\u0306");
2802: break; // n breve
2803: case 376 :
2804: buf.append("\u00d7");
2805: break; // multiply
2806: case 8364 :
2807: buf.append("\u1e5b");
2808: break; // r underring [actually underdot]
2809: case 8249 :
2810: buf.append("\u1e44");
2811: break; // N overdot
2812: case 8250 :
2813: buf.append("\u1e62");
2814: break; // S underdot
2815: case 64257 :
2816: buf.append("\u1e24");
2817: break; // H underdot
2818: case 64258 :
2819: buf.append("\u1e0c");
2820: break; // D underdot
2821: case 8225 :
2822: buf.append("\u2021");
2823: break; // daggerdbl
2824: case 8218 :
2825: buf.append("\u1e36");
2826: break; // L underdot
2827: case 8222 :
2828: buf.append("\u0113");
2829: break; // e macron
2830: case 194 :
2831: buf.append("\u1e5f");
2832: break; // r underbar
2833: case 202 :
2834: buf.append("r\u0324");
2835: break; // r underdieresis
2836: case 193 :
2837: buf.append("\u012a");
2838: break; // I macron
2839: case 8486 :
2840: case 203 :
2841: buf.append("\u016b");
2842: break; // u macron
2843: case 200 :
2844: buf.append("\u1e6c");
2845: break; // T underdot
2846: case 205 :
2847: buf.append("\u1e64");
2848: break; // S acute
2849: case 206 :
2850: buf.append("\u2020");
2851: break; // dagger
2852: case 207 :
2853: buf.append("\u0115");
2854: break; // e breve
2855: case 204 :
2856: buf.append("\u014f");
2857: break; // o breve
2858: case 211 :
2859: buf.append("\u0100");
2860: break; // A macron
2861: case 212 :
2862: buf.append("\u1e46");
2863: break; // N underdot
2864: case 210 :
2865: buf.append("\u1e3b");
2866: break; // l underbar
2867: case 218 :
2868: buf.append("\u016a");
2869: break; // U macron
2870: case 219 :
2871: buf.append("\u0179");
2872: break; // Z acute
2873: case 217 :
2874: buf.append("\u1e5a");
2875: break; // R underdot
2876: case 305 :
2877: buf.append("\u0131");
2878: break; // dotlessi
2879: case 710 :
2880: buf.append("\u1e47");
2881: break; // n underdot
2882: case 732 :
2883: buf.append("\u1e49");
2884: break; // n underbar
2885: case 175 :
2886: buf.append("\u0304");
2887: break; // macron
2888: case 728 :
2889: buf.append("\u0306");
2890: break; // breve
2891: case 729 :
2892: case 215 :
2893: buf.append("\u1e25");
2894: break; // h underdot
2895: case 730 :
2896: buf.append("\u012d");
2897: break; // i breve
2898: case 184 :
2899: buf.append("\u0327");
2900: break; // cedilla
2901: case 733 :
2902: buf.append("\u030b");
2903: break; // hungarumlaut
2904: case 731 :
2905: buf.append("\u0328");
2906: break; // ogonek
2907: case 711 :
2908: buf.append("\u030c");
2909: break; // caron
2910: case 199 :
2911: buf.append("\u012b\u0303");
2912: break; // imacron tilde
2913: case 8226 :
2914: buf.append("\u1e5d");
2915: break; // runderdot macron
2916: case 8482 :
2917: buf.append("\u016b\0306");
2918: break; // umacron breve
2919: case 8804 :
2920: buf.append("\u0101\u0301");
2921: break; // amacron acute
2922: case 8805 :
2923: buf.append("\u016b\u0301");
2924: break; // umacron acute
2925: case 8719 :
2926: buf.append("\u0113\u0301");
2927: break; // emacron acute
2928: case 170 :
2929: buf.append("\u0113\u0300");
2930: break; // emacron breve
2931: case 186 :
2932: buf.append("\u014d\u0300");
2933: break; // omacron breve
2934: case 161 :
2935: buf.append("\u0101\u0306");
2936: break; // amacron breve
2937: case 8710 :
2938: buf.append("\u0101\u0303");
2939: break; // amacron tilde
2940: case 171 :
2941: buf.append("\u012b\u0301");
2942: break; // imacron acute
2943: case 8260 :
2944: buf.append("\u1e00");
2945: break; // runderdotmacron acute
2946: case 183 :
2947: buf.append("\u1e5b\u0301");
2948: break; // runderdot acute
2949: case 8240 :
2950: buf.append("\u012b\u0306");
2951: break; // imacron breve
2952: case 63743 :
2953: buf.append("\u016b\u0303");
2954: break; // umacron tilde
2955: default :
2956: buf.append(c);
2957: if ((int) c > 127)
2958: System.out.println("char " + c + " " + (int) c);
2959: break;
2960: }
2961: }
2962: return buf.toString();
2963: }
2964:
2965: static public String normanToUnicodeOld(String inp)
2966: {
2967: StringBuffer buf = new StringBuffer();
2968: for (int i = 0; i < inp.length(); i++)
2969: {
2970: char c = inp.charAt(i);
2971: switch (c)
2972: {
2973: case 1 :
2974: buf.append("\u00d0");
2975: break; // Eth
2976: case 2 :
2977: buf.append("\u00f0");
2978: break; // eth
2979: case 3 :
2980: buf.append("\u0141");
2981: break; // Lslash
2982: case 4 :
2983: buf.append("\u0142");
2984: break; // lslash
2985: case 5 :
2986: buf.append("\u0160");
2987: break; // S caron
2988: case 6 :
2989: buf.append("\u0161");
2990: break; // s caron
2991: case 7 :
2992: buf.append("\u00dd");
2993: break; // Y acute
2994: case 8 :
2995: buf.append("\u00fd");
2996: break; // y acute
2997: case 11 :
2998: buf.append("\u00de");
2999: break; // Thorn
3000: case 12 :
3001: buf.append("\u00fe");
3002: break; // thorn
3003: case 14 :
3004: buf.append("\u017d");
3005: break; // Z caron
3006: case 15 :
3007: buf.append("\u017e");
3008: break; // z caron
3009: case 17 :
3010: buf.append("\u0073");
3011: break; // asciitilde
3012: case 18 :
3013: buf.append("j\u0305");
3014: break; // j macron [does a single char exist?]
3015: case 19 :
3016: buf.append("^");
3017: break; // circumflex
3018: case 20 :
3019: buf.append("\u0303");
3020: break; // tilde
3021: case 21 :
3022: buf.append("\u00bd");
3023: break; // onehalf
3024: case 22 :
3025: buf.append("\u00bc");
3026: break; // onequarter
3027: case 23 :
3028: buf.append("\u00b9");
3029: break; // onesuperior
3030: case 24 :
3031: buf.append("\u00be");
3032: break; // threequarters
3033: case 25 :
3034: buf.append("\u00b3");
3035: break; // threesuperior
3036: case 26 :
3037: buf.append("\u00b2");
3038: break; // twosuperior
3039: case 27 :
3040: buf.append("\u00a6");
3041: break; // brokenbar
3042: case 28 :
3043: buf.append("-");
3044: break; // minus
3045: case 29 :
3046: buf.append("\u00d7");
3047: break; // multiply
3048: case 39 :
3049: buf.append("'");
3050: break; // quotesingle
3051: case 94 :
3052: buf.append("\u0302");
3053: break; // circumflex
3054: case 96 :
3055: buf.append("\u0300");
3056: break; // grave
3057: case 128 :
3058: buf.append("\u00c4");
3059: break; // A dieresis
3060: case 129 :
3061: buf.append("\u00c5");
3062: break; // A ring
3063: case 131 :
3064: buf.append("\u00c9");
3065: break; // E acute
3066: case 132 :
3067: buf.append("\u00d1");
3068: break; // N tilde
3069: case 133 :
3070: buf.append("\u00d6");
3071: break; // O dieresis
3072: case 134 :
3073: buf.append("\u00dc");
3074: break; // U dieresis
3075: case 135 :
3076: buf.append("\u00e1");
3077: break; // a acute
3078: case 136 :
3079: buf.append("\u00e0");
3080: break; // a grave
3081: case 137 :
3082: buf.append("\u00e2");
3083: break; // a circumflex
3084: case 138 :
3085: buf.append("\u00e4");
3086: break; // a dieresis
3087: case 139 :
3088: buf.append("\u00e3");
3089: break; // a tilde
3090: case 140 :
3091: buf.append("\u0101");
3092: break; // a macron
3093: case 141 :
3094: buf.append("\u00e7");
3095: break; // c cedilla
3096: case 142 :
3097: buf.append("\u00e9");
3098: break; // e acute
3099: case 143 :
3100: buf.append("\u00e8");
3101: break; // e grave
3102: case 144 :
3103: buf.append("\u00ea");
3104: break; // e circumflex
3105: case 145 :
3106: buf.append("\u00eb");
3107: break; // e dieresis
3108: case 146 :
3109: buf.append("\u00ed");
3110: break; // i acute
3111: case 147 :
3112: buf.append("\u00ec");
3113: break; // i grave
3114: case 148 :
3115: buf.append("\u00ee");
3116: break; // i circumflex
3117: case 149 :
3118: buf.append("\u00ef");
3119: break; // i dieresis
3120: case 150 :
3121: buf.append("\u00f1");
3122: break; // n tilde
3123: case 151 :
3124: buf.append("\u00f3");
3125: break; // o acute
3126: case 152 :
3127: buf.append("\u00f2");
3128: break; // o grave
3129: case 153 :
3130: buf.append("\u00f4");
3131: break; // o circumflex
3132: case 154 :
3133: buf.append("\u00f6");
3134: break; // o dieresis
3135: case 155 :
3136: buf.append("\u00f5");
3137: break; // o tilde
3138: case 156 :
3139: buf.append("\u00fa");
3140: break; // u acute
3141: case 157 :
3142: buf.append("\u00f9");
3143: break; // u grave
3144: case 158 :
3145: buf.append("\u00fb");
3146: break; // u circumflex
3147: case 159 :
3148: buf.append("\u00fc");
3149: break; // u dieresis
3150: case 160 :
3151: buf.append("\u1e6d");
3152: break; // t underdot
3153: case 161 :
3154: buf.append("\u00b0");
3155: break; // degree
3156: case 162 :
3157: buf.append("\u1ebd");
3158: break; // e tilde
3159: case 163 :
3160: buf.append("\u00a3");
3161: break; // sterling
3162: case 164 :
3163: buf.append("\u00a7");
3164: break; // section
3165: case 166 :
3166: buf.append("\u00b6");
3167: break; // paragraph
3168: case 167 :
3169: buf.append("\u015b");
3170: break; // s acute
3171: case 168 :
3172: buf.append("\u1e5b");
3173: break; // r underdot
3174: case 169 :
3175: buf.append("\u1e67");
3176: break; // s caron
3177: case 171 :
3178: buf.append("\u0301");
3179: break; // acute
3180: case 172 :
3181: buf.append("\u0308");
3182: break; // dieresis
3183: case 173 :
3184: buf.append("\u1e6d");
3185: break; // t underdot
3186: case 174 :
3187: buf.append("\u00c6");
3188: break; // AE
3189: case 175 :
3190: buf.append("\u014d");
3191: break; // o macron
3192: case 176 :
3193: buf.append("\u0129");
3194: break; // i tilde
3195: case 177 :
3196: buf.append("\u00b1");
3197: break; // plusminus
3198: case 180 :
3199: buf.append("\u012b");
3200: break; // i macron
3201: case 181 :
3202: buf.append("\u1e43");
3203: break; // m underdot
3204: case 182 :
3205: buf.append("\u1e0d");
3206: break; // d underdot
3207: case 183 :
3208: buf.append("\u1e63");
3209: break; // s underdot
3210: case 185 :
3211: buf.append("\u017a");
3212: break; // z acute
3213: case 186 :
3214: buf.append("\u1e45");
3215: break; // n overdot
3216: case 189 :
3217: buf.append("\u0169");
3218: break; // u tilde
3219: case 190 :
3220: buf.append("\u00e6");
3221: break; // ae
3222: case 191 :
3223: buf.append("\u00f8");
3224: break; // oslash
3225: case 192 :
3226: buf.append("\u0304\u0306");
3227: break; // macron breve
3228: case 194 :
3229: buf.append("\u1e37");
3230: break; //
3231: case 195 :
3232: buf.append("j\u0305");
3233: break; // j macron [does a single char exist?]
3234: case 196 :
3235: buf.append("\u0103");
3236: break; // a breve
3237: case 197 :
3238: buf.append("\u016d");
3239: break; // u breve
3240: case 200 :
3241: buf.append("\u1e42");
3242: break; // M underdot
3243: case 201 :
3244: buf.append("\u2026");
3245: break; // ellipsis
3246: case 203 :
3247: buf.append("\u00c0");
3248: break; // A grave
3249: case 204 :
3250: buf.append("\u00c3");
3251: break; // A tilde
3252: case 205 :
3253: buf.append("\u00d5");
3254: break; // O tilde
3255: case 206 :
3256: buf.append("m\u0306");
3257: break; // m breve
3258: case 207 :
3259: buf.append("\u0153");
3260: break; // oe
3261: case 208 :
3262: buf.append("\u2013");
3263: break; // endash
3264: case 209 :
3265: buf.append("\u2014");
3266: break; // emdash
3267: case 210 :
3268: buf.append("\u201c");
3269: break; // quotedblleft
3270: case 211 :
3271: buf.append("\u201d");
3272: break; // quotedblright
3273: case 212 :
3274: buf.append("\u2018");
3275: break; // quoteleft
3276: case 213 :
3277: buf.append("\u2019");
3278: break; // quoteright
3279: case 214 :
3280: buf.append("\u1e37");
3281: break; // l underring [actually underdot]
3282: case 215 :
3283: buf.append("\u1e41");
3284: break; // m overdot
3285: case 216 :
3286: buf.append("n\u0306");
3287: break; // n breve
3288: case 217 :
3289: buf.append("\u00d7");
3290: break; // multiply
3291: case 219 :
3292: buf.append("\u1e5b");
3293: break; // r underring [actually underdot]
3294: case 220 :
3295: buf.append("\u1e44");
3296: break; // N overdot
3297: case 221 :
3298: buf.append("\u1e62");
3299: break; // S underdot
3300: case 222 :
3301: buf.append("\u1e24");
3302: break; // H underdot
3303: case 223 :
3304: buf.append("\u1e0c");
3305: break; // D underdot
3306: case 224 :
3307: buf.append("\u2021");
3308: break; // daggerdbl
3309: case 226 :
3310: buf.append("\u1e36");
3311: break; // L underdot
3312: case 227 :
3313: buf.append("\u0113");
3314: break; // e macron
3315: case 229 :
3316: buf.append("\u1e5f");
3317: break; // r underbar
3318: case 230 :
3319: buf.append("r\u0324");
3320: break; // r underdieresis
3321: case 231 :
3322: buf.append("\u012a");
3323: break; // I macron
3324: case 232 :
3325: buf.append("\u016b");
3326: break; // u macron
3327: case 233 :
3328: buf.append("\u01e6c");
3329: break; // T underdot
3330: case 234 :
3331: buf.append("\u1e64");
3332: break; // S acute
3333: case 235 :
3334: buf.append("\u2020");
3335: break; // dagger
3336: case 236 :
3337: buf.append("\u0115");
3338: break; // e breve
3339: case 237 :
3340: buf.append("\u014f");
3341: break; // o breve
3342: case 238 :
3343: buf.append("\u0100");
3344: break; // A macron
3345: case 239 :
3346: buf.append("\u1e46");
3347: break; // N underdot
3348: case 241 :
3349: buf.append("\u1e3b");
3350: break; // l underbar
3351: case 242 :
3352: buf.append("\u016a");
3353: break; // U macron
3354: case 243 :
3355: buf.append("\u0179");
3356: break; // Z acute
3357: case 244 :
3358: buf.append("\u1e5a");
3359: break; // R underdot
3360: case 245 :
3361: buf.append("\u0131");
3362: break; // dotlessi
3363: case 246 :
3364: buf.append("\u1e47");
3365: break; // n underdot
3366: case 247 :
3367: buf.append("\u1e49");
3368: break; // n underbar
3369: case 248 :
3370: buf.append("\u0304");
3371: break; // macron
3372: case 249 :
3373: buf.append("\u0306");
3374: break; // breve
3375: case 250 :
3376: buf.append("\u1e25");
3377: break; // h underdot
3378: case 251 :
3379: buf.append("\u012d");
3380: break; // i breve
3381: case 252 :
3382: buf.append("\u0327");
3383: break; // cedilla
3384: case 253 :
3385: buf.append("\u030b");
3386: break; // hungarumlaut
3387: case 254 :
3388: buf.append("\u0328");
3389: break; // ogonek
3390: case 255 :
3391: buf.append("\u030c");
3392: break; // caron
3393: case 130 :
3394: buf.append("\u012b\u0303");
3395: break; // imacron tilde
3396: case 165 :
3397: buf.append("\u1e5d");
3398: break; // runderdot macron
3399: case 170 :
3400: buf.append("\u016b\0306");
3401: break; // umacron breve
3402: case 178 :
3403: buf.append("\u0101\u0301");
3404: break; // amacron acute
3405: case 179 :
3406: buf.append("\u016b\u0301");
3407: break; // umacron acute
3408: case 184 :
3409: buf.append("\u0113\u0301");
3410: break; // emacron acute
3411: case 187 :
3412: buf.append("\u0113\u0300");
3413: break; // emacron breve
3414: case 188 :
3415: buf.append("\u014d\u0300");
3416: break; // omacron breve
3417: case 193 :
3418: buf.append("\u0101\u0306");
3419: break; // amacron breve
3420: case 198 :
3421: buf.append("\u0101\u0303");
3422: break; // amacron tilde
3423: case 199 :
3424: buf.append("\u012b\u0301");
3425: break; // imacron acute
3426: case 218 :
3427: buf.append("\u1e00");
3428: break; // runderdotmacron acute
3429: case 225 :
3430: buf.append("\u1e5b\u0301");
3431: break; // runderdot acute
3432: case 228 :
3433: buf.append("\u012b\u0306");
3434: break; // imacron breve
3435: case 240 :
3436: buf.append("\u016b\u0303");
3437: break; // umacron tilde
3438: default :
3439: buf.append(c);
3440: break;
3441: }
3442: }
3443: return buf.toString();
3444: }
3445:
3446: static public String normanToUnicodeNew(String inp)
3447: {
3448: StringBuffer buf = new StringBuffer();
3449: for (int i = 0; i < inp.length(); i++)
3450: {
3451: char c = inp.charAt(i);
3452: switch (c)
3453: {
3454: case 1 :
3455: buf.append("\u00d0");
3456: break; // Eth
3457: case 2 :
3458: buf.append("\u00f0");
3459: break; // eth
3460: case 3 :
3461: buf.append("\u0141");
3462: break; // Lslash
3463: case 4 :
3464: buf.append("\u0142");
3465: break; // lslash
3466: case 5 :
3467: buf.append("\u0160");
3468: break; // S caron
3469: case 6 :
3470: buf.append("\u0161");
3471: break; // s caron
3472: case 7 :
3473: buf.append("\u00dd");
3474: break; // Y acute
3475: case 8 :
3476: buf.append("\u00fd");
3477: break; // y acute
3478: case 11 :
3479: buf.append("\u00de");
3480: break; // Thorn
3481: case 12 :
3482: buf.append("\u00fe");
3483: break; // thorn
3484: case 14 :
3485: buf.append("\u017d");
3486: break; // Z caron
3487: case 15 :
3488: buf.append("\u017e");
3489: break; // z caron
3490: case 17 :
3491: buf.append("\u0073");
3492: break; // asciitilde
3493: case 18 :
3494: buf.append("j\u0305");
3495: break; // j macron [does a single char exist?]
3496: case 19 :
3497: buf.append("^");
3498: break; // circumflex
3499: case 20 :
3500: buf.append("\u0303");
3501: break; // tilde
3502: case 21 :
3503: buf.append("\u00bd");
3504: break; // onehalf
3505: case 22 :
3506: buf.append("\u00bc");
3507: break; // onequarter
3508: case 23 :
3509: buf.append("\u00b9");
3510: break; // onesuperior
3511: case 24 :
3512: buf.append("\u00be");
3513: break; // threequarters
3514: case 25 :
3515: buf.append("\u00b3");
3516: break; // threesuperior
3517: case 26 :
3518: buf.append("\u00b2");
3519: break; // twosuperior
3520: case 27 :
3521: buf.append("\u00a6");
3522: break; // brokenbar
3523: case 28 :
3524: buf.append("-");
3525: break; // minus
3526: case 29 :
3527: buf.append("\u00d7");
3528: break; // multiply
3529: case 39 :
3530: buf.append("'");
3531: break; // quotesingle
3532: case 94 :
3533: buf.append("\u0302");
3534: break; // circumflex
3535: case 96 :
3536: buf.append("\u0300");
3537: break; // grave
3538: case 196 :
3539: buf.append("\u00c4");
3540: break; // A dieresis
3541: case 197 :
3542: buf.append("\u00c5");
3543: break; // A ring
3544: case 201 :
3545: buf.append("\u00c9");
3546: break; // E acute
3547: case 209 :
3548: buf.append("\u00d1");
3549: break; // N tilde
3550: case 214 :
3551: buf.append("\u00d6");
3552: break; // O dieresis
3553: case 220 :
3554: buf.append("\u00dc");
3555: break; // U dieresis
3556: case 225 :
3557: buf.append("\u00e1");
3558: break; // a acute
3559: case 224 :
3560: buf.append("\u00e0");
3561: break; // a grave
3562: case 226 :
3563: buf.append("\u00e2");
3564: break; // a circumflex
3565: case 228 :
3566: buf.append("\u00e4");
3567: break; // a dieresis
3568: case 227 :
3569: buf.append("\u00e3");
3570: break; // a tilde
3571: case 229 :
3572: buf.append("\u0101");
3573: break; // a macron
3574: case 231 :
3575: buf.append("\u00e7");
3576: break; // c cedilla
3577: case 233 :
3578: buf.append("\u00e9");
3579: break; // e acute
3580: case 232 :
3581: buf.append("\u00e8");
3582: break; // e grave
3583: case 234 :
3584: buf.append("\u00ea");
3585: break; // e circumflex
3586: case 235 :
3587: buf.append("\u00eb");
3588: break; // e dieresis
3589: case 237 :
3590: buf.append("\u00ed");
3591: break; // i acute
3592: case 236 :
3593: buf.append("\u00ec");
3594: break; // i grave
3595: case 238 :
3596: buf.append("\u00ee");
3597: break; // i circumflex
3598: case 239 :
3599: buf.append("\u00ef");
3600: break; // i dieresis
3601: case 241 :
3602: buf.append("\u00f1");
3603: break; // n tilde
3604: case 243 :
3605: buf.append("\u00f3");
3606: break; // o acute
3607: case 242 :
3608: buf.append("\u00f2");
3609: break; // o grave
3610: case 244 :
3611: buf.append("\u00f4");
3612: break; // o circumflex
3613: case 246 :
3614: buf.append("\u00f6");
3615: break; // o dieresis
3616: case 245 :
3617: buf.append("\u00f5");
3618: break; // o tilde
3619: case 250 :
3620: buf.append("\u00fa");
3621: break; // u acute
3622: case 249 :
3623: buf.append("\u00f9");
3624: break; // u grave
3625: case 251 :
3626: buf.append("\u00fb");
3627: break; // u circumflex
3628: case 252 :
3629: buf.append("\u00fc");
3630: break; // u dieresis
3631: case 8224 :
3632: buf.append("\u1e6d");
3633: break; // t underdot
3634: case 176 :
3635: buf.append("\u00b0");
3636: break; // degree
3637: case 162 :
3638: buf.append("\u1ebd");
3639: break; // e tilde
3640: case 163 :
3641: buf.append("\u00a3");
3642: break; // sterling
3643: case 167 :
3644: buf.append("\u00a7");
3645: break; // section
3646: case 182 :
3647: buf.append("\u00b6");
3648: break; // paragraph
3649: case 223 :
3650: buf.append("\u015b");
3651: break; // s acute
3652: case 174 :
3653: buf.append("\u1e5b");
3654: break; // r underdot
3655: case 169 :
3656: buf.append("\u1e45");
3657: break; // n overdot
3658: case 180 :
3659: buf.append("\u0301");
3660: break; // acute
3661: case 168 :
3662: buf.append("\u0308");
3663: break; // dieresis
3664: case 8800 :
3665: buf.append("\u1e6d");
3666: break; // t underdot
3667: case 198 :
3668: buf.append("\u00c6");
3669: break; // AE
3670: case 216 :
3671: buf.append("\u014d");
3672: break; // o macron
3673: case 8734 :
3674: buf.append("\u0129");
3675: break; // i tilde
3676: case 177 :
3677: buf.append("\u00b1");
3678: break; // plusminus
3679: case 165 :
3680: buf.append("\u012b");
3681: break; // i macron
3682: case 181 :
3683: buf.append("\u1e43");
3684: break; // m underdot
3685: case 8706 :
3686: buf.append("\u1e0d");
3687: break; // d underdot
3688: case 8721 :
3689: buf.append("\u1e63");
3690: break; // s underdot
3691: case 960 :
3692: buf.append("\u017a");
3693: break; // z acute
3694: case 8747 :
3695: buf.append("\u1e45");
3696: break; // n overdot
3697: case 937 :
3698: buf.append("\u0169");
3699: break; // u tilde
3700: case 230 :
3701: buf.append("\u00e6");
3702: break; // ae
3703: case 248 :
3704: buf.append("\u00f8");
3705: break; // oslash
3706: case 191 :
3707: buf.append("\u0304\u0306");
3708: break; // macron breve
3709: case 172 :
3710: buf.append("\u1e37");
3711: break; //
3712: case 8730 :
3713: buf.append("j\u0305");
3714: break; // j macron [does a single char exist?]
3715: case 402 :
3716: buf.append("\u0103");
3717: break; // a breve
3718: case 8776 :
3719: buf.append("\u016d");
3720: break; // u breve
3721: case 187 :
3722: buf.append("\u1e42");
3723: break; // M underdot
3724: case 8230 :
3725: buf.append("\u2026");
3726: break; // ellipsis
3727: case 192 :
3728: buf.append("\u00c0");
3729: break; // A grave
3730: case 195 :
3731: buf.append("\u00c3");
3732: break; // A tilde
3733: case 213 :
3734: buf.append("\u00d5");
3735: break; // O tilde
3736: case 338 :
3737: buf.append("m\u0306");
3738: break; // m breve
3739: case 339 :
3740: buf.append("\u0153");
3741: break; // oe
3742: case 8211 :
3743: buf.append("\u2013");
3744: break; // endash
3745: case 8212 :
3746: buf.append("\u2014");
3747: break; // emdash
3748: case 8220 :
3749: buf.append("\u201c");
3750: break; // quotedblleft
3751: case 8221 :
3752: buf.append("\u201d");
3753: break; // quotedblright
3754: case 8216 :
3755: buf.append("\u2018");
3756: break; // quoteleft
3757: case 8217 :
3758: buf.append("\u2019");
3759: break; // quoteright
3760: case 247 :
3761: buf.append("\u1e37");
3762: break; // l underring [actually underdot]
3763: case 9674 :
3764: buf.append("\u1e41");
3765: break; // m overdot
3766: case 255 :
3767: buf.append("n\u0306");
3768: break; // n breve
3769: case 376 :
3770: buf.append("\u00d7");
3771: break; // multiply
3772: case 8364 :
3773: buf.append("\u1e5b");
3774: break; // r underring [actually underdot]
3775: case 8249 :
3776: buf.append("\u1e44");
3777: break; // N overdot
3778: case 8250 :
3779: buf.append("\u1e62");
3780: break; // S underdot
3781: case 64257 :
3782: buf.append("\u1e24");
3783: break; // H underdot
3784: case 64258 :
3785: buf.append("\u1e0c");
3786: break; // D underdot
3787: case 8225 :
3788: buf.append("\u2021");
3789: break; // daggerdbl
3790: case 8218 :
3791: buf.append("\u1e36");
3792: break; // L underdot
3793: case 8222 :
3794: buf.append("\u0113");
3795: break; // e macron
3796: case 194 :
3797: buf.append("\u1e5f");
3798: break; // r underbar
3799: case 202 :
3800: buf.append("r\u0324");
3801: break; // r underdieresis
3802: case 193 :
3803: buf.append("\u012a");
3804: break; // I macron
3805: case 203 :
3806: buf.append("\u016b");
3807: break; // u macron
3808: case 200 :
3809: buf.append("\u1e6c");
3810: break; // T underdot
3811: case 205 :
3812: buf.append("\u1e64");
3813: break; // S acute
3814: case 206 :
3815: buf.append("\u2020");
3816: break; // dagger
3817: case 207 :
3818: buf.append("\u0115");
3819: break; // e breve
3820: case 204 :
3821: buf.append("\u014f");
3822: break; // o breve
3823: case 211 :
3824: buf.append("\u0100");
3825: break; // A macron
3826: case 212 :
3827: buf.append("\u1e46");
3828: break; // N underdot
3829: case 210 :
3830: buf.append("\u1e3b");
3831: break; // l underbar
3832: case 218 :
3833: buf.append("\u016a");
3834: break; // U macron
3835: case 219 :
3836: buf.append("\u0179");
3837: break; // Z acute
3838: case 217 :
3839: buf.append("\u1e5a");
3840: break; // R underdot
3841: case 305 :
3842: buf.append("\u0131");
3843: break; // dotlessi
3844: case 710 :
3845: buf.append("\u1e47");
3846: break; // n underdot
3847: case 732 :
3848: buf.append("\u1e49");
3849: break; // n underbar
3850: case 175 :
3851: buf.append("\u0304");
3852: break; // macron
3853: case 728 :
3854: buf.append("\u0306");
3855: break; // breve
3856: case 729 :
3857: buf.append("\u1e25");
3858: break; // h underdot
3859: case 730 :
3860: buf.append("\u012d");
3861: break; // i breve
3862: case 184 :
3863: buf.append("\u0327");
3864: break; // cedilla
3865: case 733 :
3866: buf.append("\u030b");
3867: break; // hungarumlaut
3868: case 731 :
3869: buf.append("\u0328");
3870: break; // ogonek
3871: case 711 :
3872: buf.append("\u030c");
3873: break; // caron
3874: case 199 :
3875: buf.append("\u012b\u0303");
3876: break; // imacron tilde
3877: case 8226 :
3878: buf.append("\u1e5d");
3879: break; // runderdot macron
3880: case 8482 :
3881: buf.append("\u016b\0306");
3882: break; // umacron breve
3883: case 8804 :
3884: buf.append("\u0101\u0301");
3885: break; // amacron acute
3886: case 8805 :
3887: buf.append("\u016b\u0301");
3888: break; // umacron acute
3889: case 8719 :
3890: buf.append("\u0113\u0301");
3891: break; // emacron acute
3892: case 170 :
3893: buf.append("\u0113\u0300");
3894: break; // emacron breve
3895: case 186 :
3896: buf.append("\u014d\u0300");
3897: break; // omacron breve
3898: case 161 :
3899: buf.append("\u0101\u0306");
3900: break; // amacron breve
3901: case 8710 :
3902: buf.append("\u0101\u0303");
3903: break; // amacron tilde
3904: case 171 :
3905: buf.append("\u012b\u0301");
3906: break; // imacron acute
3907: case 8260 :
3908: buf.append("\u1e00");
3909: break; // runderdotmacron acute
3910: case 183 :
3911: buf.append("\u1e5b\u0301");
3912: break; // runderdot acute
3913: case 8240 :
3914: buf.append("\u012b\u0306");
3915: break; // imacron breve
3916: case 63743 :
3917: buf.append("\u016b\u0303");
3918: break; // umacron tilde
3919: default :
3920: buf.append(c);
3921: break;
3922: }
3923: }
3924: return buf.toString();
3925: }
3926:
3927: public static ConversionProperties getFieldNamesAndDestTableName(String create, String query, String tableName)
3928: {
3929: String[] fieldNames = null;
3930: String destTableName = null;
3931: // determine destTableName from createStatement or from source table
3932: // name
3933: if (!create.equals(""))
3934: {
3935: int fromIndex = create.toLowerCase().indexOf("table") + 5;
3936: int toIndex = create.indexOf("(");
3937: int endIndex = create.indexOf(")", toIndex);
3938:
3939: destTableName = create.substring(fromIndex, toIndex).replaceAll(beanDest.getQC(), "").trim();
3940: System.out.println("destTable " + destTableName);
3941: // retrieve field_names from select statement
3942: // TODO problem with different fieldNames in create statement will
3943: // overwrite them
3944: if (query.indexOf("*") < 0)
3945: {
3946: int selectEndIndex = query.indexOf("from");
3947: StringTokenizer tokenizer = new StringTokenizer(query.substring(6, selectEndIndex), ",");
3948: int numFields = tokenizer.countTokens();
3949: fieldNames = new String[numFields];
3950: int fieldIndex = 0;
3951: while (tokenizer.hasMoreTokens())
3952: {
3953: String fieldName = tokenizer.nextToken().trim();
3954: fieldNames[fieldIndex] = convertText(fieldName);
3955: System.out.println(fieldNames[fieldIndex]);
3956: fieldIndex++;
3957: }
3958:
3959: }
3960: else
3961: {
3962: // use create statement for field names
3963: StringTokenizer tokenizer = new StringTokenizer(create.substring(toIndex + 1, endIndex), ",");
3964: int numFields = tokenizer.countTokens();
3965: fieldNames = new String[numFields];
3966: int fieldIndex = 0;
3967: while (tokenizer.hasMoreTokens())
3968: {
3969: String fieldName = tokenizer.nextToken().trim();
3970: int index = fieldName.lastIndexOf(" ");
3971: fieldNames[fieldIndex] = fieldName.substring(0, index);
3972: System.out.println(fieldNames[fieldIndex]);
3973: fieldIndex++;
3974: }
3975: }
3976: }
3977: else
3978: {
3979: destTableName = convertText(tableName);
3980:
3981: // retrieve field_names from select statement
3982: if (query.indexOf("*") < 0)
3983: {
3984: int selectEndIndex = query.indexOf("from");
3985: StringTokenizer tokenizer = new StringTokenizer(query.substring(6, selectEndIndex), ",");
3986: int numFields = tokenizer.countTokens();
3987: fieldNames = new String[numFields];
3988: int fieldIndex = 0;
3989: while (tokenizer.hasMoreTokens())
3990: {
3991: String fieldName = tokenizer.nextToken().trim();
3992: fieldNames[fieldIndex] = beanDest.getQC() + convertText(fieldName) + beanDest.getQC();
3993: // System.out.println("field "+ fieldNames[fieldIndex]);
3994: fieldIndex++;
3995: }
3996:
3997: }
3998: else
3999: {
4000: Vector fieldNamesVec = bean.getColumnNames();
4001: fieldNames = new String[fieldNamesVec.size()];
4002: int fieldIndex = -1;
4003: for (Iterator iter = fieldNamesVec.iterator(); iter.hasNext();)
4004: {
4005: String element = (String) iter.next();
4006: fieldNames[++fieldIndex] = beanDest.getQC() + convertText(element) + beanDest.getQC();
4007: // System.out.println("field " + fieldNames[fieldIndex]);
4008: }
4009: }
4010: }
4011: return new ConversionProperties(destTableName, fieldNames);
4012: }
4013:
4014: /**
4015: * creates an insert into statement for the specified table and given field
4016: * names
4017: *
4018: * @param destTableName
4019: * @param fieldNames
4020: * @return
4021: */
4022: public static StringBuffer createInsertCommand(String destTableName, String[] fieldNames)
4023: {
4024: StringBuffer command = new StringBuffer();
4025: command.append("INSERT INTO ");
4026: command.append(beanDest.getQC());
4027: command.append(destTableName); //convertText((String)
4028: // names.get(tbIndex)));
4029: command.append(beanDest.getQC());
4030: command.append(" (");
4031: for (int i = 0; i < fieldNames.length; i++)
4032: {
4033: command.append(fieldNames[i]);
4034: if (i < fieldNames.length - 1)
4035: command.append(",");
4036: }
4037: command.append(") ");
4038:
4039: command.append(" values ( ");
4040: // add a question marks for every field
4041: for (int i = 0; i < bean.getColumnNames().size() - 1; ++i)
4042: command.append("?,");
4043: command.append("?)");
4044: return command;
4045: }
4046:
4047: public static StringBuffer createUpdateCommand(String destTableName, String[] fieldNames, String id)
4048: {
4049: StringBuffer command = new StringBuffer();
4050:
4051: command.append("UPDATE ");
4052: command.append(beanDest.getQC());
4053: command.append(destTableName);
4054: //command.append(convertText((String) names.get(tbIndex)));
4055: command.append(beanDest.getQC());
4056: command.append(" SET ");
4057:
4058: int size = bean.getColumnNames().size();
4059: for (int i = 0; i < size - 1; ++i)
4060: command.append(fieldNames[i] + " = ? ,");
4061: command.append(fieldNames[size - 1] + " = ? ");
4062: command.append("WHERE " + id + " = ?");
4063: return command;
4064: }
4065:
4066: public static StringBuffer createDeleteCommand(String destTableName, String idField)
4067: {
4068: StringBuffer command = new StringBuffer();
4069:
4070: command.append("DELETE FROM");
4071: command.append(beanDest.getQC());
4072: command.append(destTableName);
4073: //command.append(convertText((String) names.get(tbIndex)));
4074: command.append(beanDest.getQC());
4075: command.append("WHERE " + idField + " = ?");
4076: return command;
4077: }
4078:
4079: public void makeTest(String table, String idField, String tempQuery) throws Exception
4080: {
4081: int counter = 0;
4082:
4083: // ****** test code *****
4084:
4085: bean.getConnection();
4086: ResultSet resultSet = null;
4087: String lastResult = "P227634.11";//"P227625.79554";//"P227625.77391";//"P116034.970998";
4088: String myQuery = "select " + bean.getQC() + idField + bean.getQC() + ",serial " + " from " + bean.getQC() + table + bean.getQC();
4089: System.out.println("Query is now " + myQuery);
4090: JDialog statusDialog = new JDialog();
4091: statusDialog.setTitle("Status Information");
4092: JLabel status = new JLabel("actual DataSet : ");
4093: JLabel status2 = new JLabel(Integer.toString(++counter));
4094: JLabel status3 = new JLabel(lastResult);
4095:
4096: JPanel statusPanel = new JPanel();
4097: JPanel statusPanel2 = new JPanel();
4098: statusPanel.add(status);
4099: statusPanel.add(status2);
4100: statusPanel2.add(status3);
4101: statusDialog.getContentPane().add(statusPanel, "North");
4102: statusDialog.getContentPane().add(statusPanel2, "Center");
4103: statusDialog.setLocation(400, 500);
4104: statusDialog.setSize(300, 150);
4105: statusDialog.setVisible(true);
4106: while (true)
4107: {
4108: if (!statusDialog.isVisible())
4109: statusDialog.setVisible(true);
4110: tempQuery = myQuery + " where " + bean.getQC() + idField + bean.getQC() + ">'" + lastResult + "'";
4111: resultSet = bean.makeQuery(tempQuery, 1);
4112: if (resultSet == null)
4113: {
4114: System.out.println("lastResult was " + lastResult + " counter was " + counter);
4115: break;
4116: }
4117: else
4118: {
4119: resultSet.next();
4120: lastResult = resultSet.getString(1);
4121: counter++;
4122: status2.setText(Integer.toString(counter));
4123: status3.setText(lastResult + " " + resultSet.getString(2));
4124: if (counter % 100 == 0)
4125: {
4126: System.out.println("actual Result was " + lastResult + " counter was " + counter);
4127: // break;
4128: }
4129: }
4130: resultSet = null;
4131: }
4132: System.exit(0);
1.77 rogo 4133:
1.79 rogo 4134: //****** end Test ******
1.77 rogo 4135:
1.79 rogo 4136: }
1.55 rogo 4137: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>