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