Annotation of FM2SQL/DBBean.java, revision 1.16
1.11 rogo 1: /*
2: * DBBean.java -- Class that ecapsulates all database actions
3: * Filemake to SQL Converter
4: * Copyright (C) 2004 Robert Gordesch (rogo@mpiwg-berlin.mpg.de)
5: * This program is free software; you can redistribute it and/or modify it
6: * under the terms of the GNU General Public License as published by the Free
7: * Software Foundation; either version 2 of the License, or (at your option)
8: * any later version. Please read license.txt for the full details. A copy of
9: * the GPL may be found at http://www.gnu.org/copyleft/lgpl.html You should
10: * have received a copy of the GNU General Public License along with this
11: * program; if not, write to the Free Software Foundation, Inc., 59 Temple
12: * Place, Suite 330, Boston, MA 02111-1307 USA Created on 15.09.2003 by
13: * rogo
14: */
1.3 rogo 15:
16:
1.1 rogo 17: import java.sql.*;
1.15 rogo 18: import java.text.DateFormat;
1.1 rogo 19: import java.util.*;
1.15 rogo 20:
1.1 rogo 21: import com.fmi.jdbc.*;
22:
23: /**
24: *
25: *
26: * DBBean - Database bean
27: *
28: *<p> a Javabean to perform queries on a JDBC Database,
29: * or excute any other SQL statement
30: * </p>
31: * <p>
32: * Usage:
33: * <pre>
34: * DBBean bean = new DBBean();
35: * // setting user and passwd
36: * bean.setUserAndPasswd("bla","bla");
37: * try
38: * {
39: * bean.setConnection("jdbc:fmpro:http://localhost");
40: * Vector names=bean.getTableNames();
41: * Vector[] result=bean.getQueryData(names.get(0).toString());
42: * // print results to screen
43: * for(int i=0;i<result[1].size();++i)
44: * {
45: * //print Header
46: * System.out.print(" "+result[1].get(i));
47: * }
48: * System.out.println();
49: * for(int j=0;j<result[0].size();++j)
50: * {
51: * Vector row=(Vector)result[0].get(j);
52: * //print rows
53: * for(int k=0;k<row.size();++k)
54: * System.out.print(" "+row.get(k));
55: * System.out.println();
56: * }
57: * } catch(Exception e)
58: * {
59: * System.out.println("Error while connecting to database"+ e);
60: * }
61: * </pre>
62: *
63: * </p>
64: * @author rogo
65: */
66: public class DBBean
67: {
68: Connection connection;
69: String url = "";
70: DatabaseMetaData dbMetaData;
71: Vector columnNames;
1.4 rogo 72: Vector ids = new Vector();
1.1 rogo 73: String user = (System.getProperty("user.name") == null) ? "" : System.getProperty("user.name"); //"postgres";
74: String passwd = ""; //"3333";//"rogo";
75: public int maxHits = 10;
76: ResultSet result;
77: String quoteChar = "";
78: Hashtable connectionPool = new Hashtable();
79: public ResultSetMetaData metaData;
80: // register DataBase Drivers
81: static {
82: try
83: {
84: DriverManager.registerDriver(new com.fmi.jdbc.JdbcDriver());
85: DriverManager.registerDriver((Driver) Class.forName("org.postgresql.Driver").newInstance());
1.9 rogo 86: DriverManager.registerDriver((Driver) Class.forName("com.mysql.jdbc.Driver").newInstance());
1.1 rogo 87: DriverManager.registerDriver((Driver) Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance());
1.9 rogo 88:
1.1 rogo 89: // wait a maximum of 10 seconds when attempting to establish a connection
90: DriverManager.setLoginTimeout(10);
91: } catch (Exception e)
92: {
93: System.out.println(e);
94: }
95: }
96: /**
97: * Constructs a database bean
98: */
99: public DBBean()
100: {
101:
102: }
103: /**
104: *Constructs a database bean
105: * and tries to connect to database
106: *specified in the jdbcConnectionURL
107: * @param jdbcConnectionURL url to connect to database
108: */
109:
110: public DBBean(String jdbcConnectionURL) throws Exception
111: {
112:
113: this.url = jdbcConnectionURL;
114:
115: connection = getConnection();
116: if (connection == null)
117: return;
118: // get the meta data for the current connection
119: DatabaseMetaData dbMetaData = (DatabaseMetaData) connection.getMetaData();
120: quoteChar = dbMetaData.getIdentifierQuoteString();
121: if (quoteChar == null)
122: quoteChar = "\""; // needed for postgres
123:
124: // create the root node of the tree
125: // get the open tables from the current connection; the FileMaker Pro
126: // JDBC driver ignores all of the parameters to this method
127:
128: // iterate over the table names and add them to the root node of the tree
129:
130: }
131: /**
132: * sets the maximum number of hits
133: */
134: public void setMaxHits(int maxHits)
135: {
136: this.maxHits = maxHits;
137: }
138: /**
139: * gets the maximum number of hits
140: */
141: public int getMaxHits()
142: {
143: return maxHits;
144: }
145:
146: /**
147: * returns the Connection if null creates a new one from the url property.
148: *
149: */
150: public Connection getConnection() throws Exception
151: {
152: ConnectionPool conPool = (ConnectionPool) connectionPool.get(url);
153: if (conPool == null)
154: {
155: connection = DriverManager.getConnection(url, user, passwd);
156: connectionPool.put(url, new ConnectionPool(url, user, passwd, connection));
157: } else
158: {
159: if (!conPool.user.equals(user) || !conPool.passwd.equals(passwd))
160: {
161: conPool.con.close();
162: conPool.user = user;
163: conPool.passwd = passwd;
164:
165: }
166: connection = conPool.con;
167: if (connection.isClosed())
168: {
169: System.out.println("Made new connection!!!");
170: connection = DriverManager.getConnection(conPool.url, conPool.user, conPool.passwd);
171: conPool.con = connection;
172: }
173: }
174: if (url != "" && connection == null)
175: connection = DriverManager.getConnection(url, user, passwd);
176: dbMetaData = connection.getMetaData();
177: quoteChar = dbMetaData.getIdentifierQuoteString();
178: if (quoteChar == null)
179: quoteChar = "\""; // needed for postgres
180:
181: return connection;
182: }
183: /**
184: * sets the connection of this DBBean to the database specified in the url
185: * property
186: */
187: public void setConnection(String url) throws Exception
188: {
189: this.url = url;
190: if (url != "")
191: connection = DriverManager.getConnection(url, user, passwd);
192: dbMetaData = connection.getMetaData();
193: quoteChar = dbMetaData.getIdentifierQuoteString();
194: if (quoteChar == null)
195: quoteChar = "\""; // needed for postgres
196: }
197: /**
198: * sets the connection of this DBBean to the database specified in the url
199: * and the url,user and passwd property of this DBBean instance
200: */
201: public void setConnection(String url, String user, String passwd) throws Exception
202: {
203: this.user = user;
204: this.passwd = passwd;
205: this.url = url;
206: if (url != "")
207: connection = DriverManager.getConnection(url, user, passwd);
208: dbMetaData = connection.getMetaData();
209: quoteChar = dbMetaData.getIdentifierQuoteString();
210: if (quoteChar == null)
211: quoteChar = "\""; // needed for postgres
212: }
213:
1.4 rogo 214: public void setIDVector(Vector ids)
215: {
216: this.ids = ids;
217: }
218:
219: /**
220: * returns a Vector containing the ID Row Name
221: **/
222: public Vector getIDVector()
223: {
224: return ids;
225: }
1.1 rogo 226: /**
227: * returns a Vector containing the Tablenames or an error message in the Vector
228: */
229: public Vector getTableNames()
230: {
231: Vector tableNameVec = new Vector();
232: try
233: {
234: if (connection == null)
235: {
236: Vector vec = new Vector();
237: vec.add("no database connection");
238: return vec;
239: }
240: if (dbMetaData == null)
241: dbMetaData = connection.getMetaData();
242: ResultSet tableNames = dbMetaData.getTables(null, null, null, null);
243: // System.out.println(dbMetaData.supportsAlterTableWithAddColumn());
244: // iterate over the table names and add them to the root node of the tree
245:
246: while (tableNames.next())
247: {
248: String tableName = tableNames.getString("TABLE_NAME");
249: tableNameVec.add(tableName);
250:
251: }
252: } catch (Exception e)
253: {
254: e.printStackTrace();
255: }
256: return tableNameVec;
257: }
258: /**
259: * returns a Vector containing the Tablenames or an error message in the Vector
260: */
261: public Vector getTableNames(String catalog)
262: {
263: Vector tableNameVec = new Vector();
264: try
265: {
266: if (connection == null)
267: {
268: Vector vec = new Vector();
269: vec.add("no database connection");
270: return vec;
271: }
272: setConnection(url.substring(0, url.lastIndexOf("/") + 1) + catalog);
273: if (dbMetaData == null)
274: dbMetaData = connection.getMetaData();
275: System.out.println("catalog " + catalog + " " + dbMetaData.getCatalogSeparator() + " " + url.substring(0, url.lastIndexOf("/") + 1));
276: ResultSet tableNames = dbMetaData.getTables(null, null, null, null);
277: // System.out.println(dbMetaData.supportsAlterTableWithAddColumn());
278: // iterate over the table names and add them to the root node of the tree
279:
280: while (tableNames.next())
281: {
282: String tableName = tableNames.getString("TABLE_NAME");
283: tableNameVec.add(tableName);
284:
285: }
286: } catch (Exception e)
287: {
288: e.printStackTrace();
289: }
290: return tableNameVec;
291: }
292:
293: /**
294: * returns a Vector containing the Catalog or an error message in the Vector
295: */
296: public Vector getCatalogs()
297: {
298: Vector tableNameVec = new Vector();
299: try
300: {
301: if (connection == null)
302: {
303: Vector vec = new Vector();
304: vec.add("no database connection");
305: return vec;
306: }
307: if (dbMetaData == null)
308: dbMetaData = connection.getMetaData();
309: ResultSet tableNames = dbMetaData.getCatalogs();
310: // System.out.println(dbMetaData.supportsAlterTableWithAddColumn());
311: // iterate over the table names and add them to the root node of the tree
312: System.out.println(tableNames.getMetaData().getColumnName(1));
313: while (tableNames.next())
314: {
315: String tableName = tableNames.getString(1);
316: tableNameVec.add(tableName);
317: //tableName = tableNames.getString(1);
318: //tableNameVec.add(tableName);
319:
320: }
321: } catch (Exception e)
322: {
323: e.printStackTrace();
324: }
325: return tableNameVec;
326: }
327:
328: /**
329: * returns a Vector containing the layoutNames for the specified Table
330: * if the database supports this otherwise Vector containing an empty String
331: */
332:
333: public Vector getLayoutNames(String tableName) throws SQLException
334: {
335: Vector layouts = new Vector();
336: if (dbMetaData instanceof DatabaseMetaDataExt)
337: layouts.add("");
338: if (dbMetaData == null)
339: dbMetaData = connection.getMetaData();
340:
341: if (dbMetaData instanceof DatabaseMetaDataExt)
342: {
343: ResultSet layoutNames = ((DatabaseMetaDataExt) dbMetaData).getLayouts(null, null, tableName, null);
344:
345: // iterate over the layout names and add them to the "Layouts" node
346: while (layoutNames.next())
347: layouts.add(layoutNames.getString("LAYOUT_NAME"));
348: }
349: return layouts;
350: }
351: /**
352: * Returns the result for select * from table
353: * with maxHits = 500 default value
354: */
355: public Vector[] getQueryData(String table) throws SQLException
356: {
357:
358: return getQueryData("SELECT * from " + quoteChar + table + quoteChar, maxHits);
359:
360: }
361:
362: /**
363: * Returns the result of the query
364: * or an Vector array of Vectors containing error messages
365: */
366: public Vector[] getQueryData(String query, FM2SQL.ProgressDialog dialog, int maxHits) throws SQLException
367: {
368: long timeStart = System.currentTimeMillis();
369: ResultSet resultSet = null;
370: if (connection == null)
371: {
372: Vector[] noData = new Vector[2];
373: //System.out.println("Exception occured");
374: noData[1] = new Vector();
375: Vector vec2 = new Vector();
376: noData[0] = new Vector();
377: vec2.add("no Connection available");
378: noData[0].add(vec2);
379: noData[1].add("Exception occured! No results available");
380: //noData[1].add("no Results were produced");
381:
382: return noData;
383: }
384: if (dialog != null)
385: dialog.progress.setValue(0);
386:
387: resultSet = makeQuery(query, maxHits);
388:
389: metaData = resultSet.getMetaData();
390: int columnCount = metaData.getColumnCount();
391: int rowCount = 0;
392: if (maxHits == 0)
393: rowCount = (metaData instanceof ResultSetMetaDataExt) ? 1000 : getRowCount(query);
394: else
395: rowCount = maxHits;
396: int counter = 0;
397: Vector tableData = new Vector();
398: Vector tableRow = new Vector();
399: // System.out.println("rowCount "+rowCount+" "+maxHits);
400: try
401: {
402: while ((tableRow = getNextRow()) != null)
403: {
404: counter++;
405: if (dialog != null)
406: dialog.progress.setValue((int) ((double) counter / (double) rowCount * 100.0));
407:
408: tableData.add(tableRow);
409:
410: }
411: } catch (Exception e)
412: {
413: // TODO Auto-generated catch block
414: e.printStackTrace();
415: }
416:
417: // retrieve the column names from the result set; the column names
418: // are used for the table header
419: columnNames = new Vector();
420:
421: for (int i = 1; i <= columnCount; i++)
422: columnNames.addElement(metaData.getColumnName(i));
423: Vector data[] = new Vector[2];
424: data[0] = tableData;
425: data[1] = columnNames;
426: System.out.println("Rows " + tableData.size() + " " + ((Vector) tableData.get(0)).size());
427: long timeEnd = System.currentTimeMillis();
428: System.out.println("Time needed for query and data retrieval " + (timeEnd - timeStart) + " ms");
429: return data;
430: }
431: /**
432: * Returns the result of the query
433: * or an Vector array of Vectors containing error messages
434: */
435: public Vector[] getQueryData(String query, int maxHits) throws SQLException
436: {
437: long timeStart = System.currentTimeMillis();
438: ResultSet resultSet = null;
439: if (connection == null)
440: {
441: Vector[] noData = new Vector[2];
442: //System.out.println("Exception occured");
443: noData[1] = new Vector();
444: Vector vec2 = new Vector();
445: noData[0] = new Vector();
446: vec2.add("no Connection available");
447: noData[0].add(vec2);
448: noData[1].add("Exception occured! No results available");
449: //noData[1].add("no Results were produced");
450:
451: return noData;
452: }
453: resultSet = makeQuery(query, maxHits);
454: metaData = resultSet.getMetaData();
455: int columnCount = metaData.getColumnCount();
456:
457: Vector tableData = new Vector();
458: while (resultSet.next())
459: {
460: //System.out.println("datatype "+(Types.LONGVARCHAR ==metaData.getColumnType(3)));
461: Vector tableRow = new Vector(), m_columnClasses = new Vector();
462: for (int i = 1; i <= columnCount; i++)
463: {
464: // repeating fields and fields from related databases may contain
465: // multliple data values; the data values are stored using
466: // a Vector which is then added to the tableRow
467: // if (metaData instanceof ResultSetMetaDataExt)
468: if ((metaData instanceof ResultSetMetaDataExt) && (((ResultSetMetaDataExt) metaData).isRelated(i) || ((ResultSetMetaDataExt) metaData).isRepeating(i)))
469: {
470: //System.out.println("Related fields");
471: // retrieve the repeating or related field contents as a
472: // com.fmi.jdbc.Array via the ResultSet.getObject method
473: com.fmi.jdbc.Array array = (com.fmi.jdbc.Array) resultSet.getObject(i);
474: // create a Vector for storing all of the data values
475: ArrayList columnData = new ArrayList();
476:
477: try
478: {
479:
480: // call the Array.getStringArray method since the data will
481: // only be displayed
482: Object[] fieldData = (Object[]) array.getArray();
483:
484: if (fieldData != null)
485: {
486: // add each value to the Vector
487: for (int j = 0; j < fieldData.length; j++)
488: {
489: if (fieldData[j] != null)
490: columnData.add(fieldData[j]);
491: }
492:
493: }
494: } catch (Exception e)
495: {
496: //System.out.println(e);
497: }
498: if (columnData.isEmpty())
499: tableRow.add(null);
500: else
501: tableRow.addElement(columnData);
502: //System.out.println(columnData);
503: //System.out.println("Related fields"+columnData.size()+" "+tableRow.size());
504:
505: m_columnClasses.addElement(java.util.Vector.class);
506: } else if (metaData.getColumnType(i) == Types.LONGVARBINARY)
507: {
508: // use the ResultSet.getObject method for retrieving images
509: // from FileMaker Pro container fields; the ResultSet.getObject
510: // method returns a java.awt.Image object for FileMaker Pro
511: // container fields
512: try
513: {
514:
515: tableRow.addElement(resultSet.getObject(i));
516: } catch (Exception e)
517: {
518: // TODO Auto-generated catch block
519: //e.printStackTrace();
520: tableRow.addElement(null);
521: }
522: //tableRow.addElement("Picture ignored");
523: m_columnClasses.addElement(java.awt.Image.class);
524: } else if (metaData.getColumnType(i) == Types.TIME)
525: {
526: // use the ResultSet.getObject method for retieving images
527: // from FileMaker Pro container fields; the ResultSet.getObject
528: // method returns a java.awt.Image object for FileMaker Pro
529: // container fields
530: try
531: {
532: tableRow.addElement(resultSet.getTime(i).toString());
533: m_columnClasses.addElement(java.sql.Time.class);
534: } catch (Exception e)
535: {
536:
537: String value = resultSet.getString(i);
538: if (value != null)
539: {
540: //System.out.println("SQLTime new "+Time.valueOf("17:00:00").toString());
541: int index = 0;
542: for (int j = 0; j < value.length(); ++j)
543: {
544: if (!Character.isLetter(value.charAt(j)))
545: index = j + 1;
546: else
547: break;
548: }
549:
550: tableRow.addElement(value.substring(0, index));
551: //m_columnClasses.addElement(java.sql.Time.class);
552: } else
553: tableRow.add(null);
554: m_columnClasses.addElement(String.class);
555: } // to catch
556:
557: } else if (metaData.getColumnType(i) == Types.DATE)
558: {
559: // use the ResultSet.getObject method for retieving images
560: // from FileMaker Pro container fields; the ResultSet.getObject
561: // method returns a java.awt.Image object for FileMaker Pro
562: // container fields
563:
564: tableRow.addElement(resultSet.getDate(i));
565: m_columnClasses.addElement(java.sql.Date.class);
566: } else if (metaData.getColumnTypeName(i) == "NUMBER")
567: {
568: // use the ResultSet.getObject method for retieving images
569: // from FileMaker Pro container fields; the ResultSet.getObject
570: // method returns a java.awt.Image object for FileMaker Pro
571: // container fields
572: try
573: {
1.13 rogo 574: tableRow.addElement(new Double(resultSet.getDouble(i)));
575: m_columnClasses.addElement(Double.class);
1.1 rogo 576:
577: } catch (Exception e)
578: {
579:
580: StringBuffer number = new StringBuffer();
581: String value = resultSet.getString(i);
582: System.out.println(value);
583: for (int c = 0; c < value.length(); ++c)
584: {
585: if (Character.isDigit(value.charAt(c)))
586: {
587: number.append(value.charAt(c));
588: }
589: }
590: if (number.length() > 0)
591: {
592: tableRow.addElement(null);
1.13 rogo 593: m_columnClasses.addElement(Double.class);
1.1 rogo 594: } else
595: tableRow.addElement(null);
596: }
597: } else
598: {
599: // all other field values are retrieved as strings and
600: // added to the tableRow Vector
601: // if(resultSet.getObject(i)!=null) System.out.println(resultSet.getObject(i));
602: try
603: {
604: byte[] b = resultSet.getBytes(i);
605: String utf8 = null;
606: if (metaData instanceof ResultSetMetaDataExt)
607: utf8 = (b == null) ? null : new String(b);
608: else
609: utf8 = (b == null) ? null : new String(b, "UTF-8");
610: utf8 = (utf8 == null) ? null : new String(utf8.getBytes("UTF-8"), "UTF-8");
611: tableRow.addElement(utf8);
612: } catch (Exception e)
613: {
614: System.out.println("Hey I Got an error" + e);
615: }
616: m_columnClasses.addElement(java.lang.String.class);
617: }
618: }
619:
620: // add the tableRow Vector to the tableData Vector
621: tableData.addElement(tableRow);
622: }
623:
624: // retrieve the column names from the result set; the column names
625: // are used for the table header
626: columnNames = new Vector();
627:
628: for (int i = 1; i <= columnCount; i++)
629: columnNames.addElement(metaData.getColumnName(i));
630: Vector data[] = new Vector[2];
631: data[0] = tableData;
632: data[1] = columnNames;
633: System.out.println("Rows " + tableData.size() + " " + ((Vector) tableData.get(0)).size());
634: long timeEnd = System.currentTimeMillis();
635: System.out.println("Time needed for query and data retrieval " + (timeEnd - timeStart) + " ms");
636: return data;
637: }
638:
639: public Vector getColumnNames()
640: {
641: if (result == null)
642: return null;
643: try
644: {
645: ResultSetMetaData metaData = result.getMetaData();
646: int columnCount = metaData.getColumnCount();
647: columnNames = new Vector();
648:
649: for (int i = 1; i <= columnCount; i++)
650: columnNames.addElement(metaData.getColumnName(i));
651: } catch (Exception e)
652: {
653: }
654: return columnNames;
655: }
656: /**
657: * makes the database Query
658: * with the numberOfHits as maximum
659: * @return the result as an ResultSet object
660: */
661: public ResultSet makeQuery(String query, int numberOfHits) throws SQLException
662: {
663: result = null;
664: Statement stm = null;
1.2 rogo 665:
1.1 rogo 666: // System.out.println("Query " + query);
667:
668: if (!connection.isClosed())
669: stm = connection.createStatement();
1.12 rogo 670: else {
671:
672:
673: try
674: {
675: connection = getConnection();
676: stm= connection.createStatement();
677: } catch (Exception e)
678: {
679: // TODO Auto-generated catch block
680: e.printStackTrace();
681: }
682: }
1.1 rogo 683: stm.setMaxRows(numberOfHits);
1.2 rogo 684: long time = System.currentTimeMillis();
685: stm.execute(query);
686: long time2 = System.currentTimeMillis();
687:
688: System.out.println("time to execute "+(time2-time));
689: // stm.setMaxRows(numberOfHits);
690:
691: result = stm.getResultSet();
692: // System.out.println(result+" "+stm.getUpdateCount());
1.1 rogo 693: metaData = result.getMetaData();
694: return result;
695: }
696: /**
697: * sets the database user
698: */
699: public void setUser(String user)
700: {
701: this.user = user;
702: }
703: /**
704: * sets the database passwd
705: */
706: public void setPasswd(String passwd)
707: {
708: this.passwd = passwd;
709: }
710:
711: /**
712: * sets the database user and passwd
713: */
714: public void setUserAndPasswd(String user, String passwd)
715: {
716: this.user = user;
717: this.passwd = passwd;
718:
719: }
720: /**
721: * just sets the connection URL
722: */
723: public void setURL(String url)
724: {
725: this.url = url;
726: }
727:
728: /**
729: * Test the database drivers features given by the DatabaseMetaData object
730: */
731: public Vector[] TestDB(DatabaseMetaData d) throws SQLException
732: {
733:
734: Vector data[] = new Vector[2];
735: Vector[] rows = new Vector[120];
736: for (int i = 0; i < rows.length; ++i)
737: rows[i] = new Vector();
738: Vector columnNames = new Vector();
739: columnNames.add("Feature");
740: columnNames.add("Supported");
741:
742: Vector cols = new Vector();
743: rows[0].add("allProceduresAreCallable");
744: rows[0].add(new Boolean(d.allProceduresAreCallable()));
745: //boolean allProceduresAreCallable() throws SQLException;
746: rows[1].add("allTablesAreSelectable");
747: rows[1].add(new Boolean(d.allTablesAreSelectable()));
748: // boolean allTablesAreSelectable() throws SQLException;
749: rows[2].add("isReadOnly");
750: rows[2].add(new Boolean(d.isReadOnly()));
751: // boolean isReadOnly() throws SQLException;
752: rows[3].add("nullsAreSortedHigh");
753: rows[3].add(new Boolean(d.nullsAreSortedHigh()));
754: // boolean nullsAreSortedHigh() throws SQLException;
755: rows[4].add("nullsAreSortedLow");
756: rows[4].add(new Boolean(d.nullsAreSortedLow()));
757: // boolean nullsAreSortedLow() throws SQLException;
758: rows[5].add("nullsAreSortedAtStart");
759: rows[5].add(new Boolean(d.nullsAreSortedAtStart()));
760: // boolean nullsAreSortedAtStart() throws SQLException;
761: rows[6].add("nullsAreSortedAtEnd");
762: rows[6].add(new Boolean(d.nullsAreSortedAtEnd()));
763: // boolean nullsAreSortedAtEnd() throws SQLException;
764: rows[7].add("usesLocalFiles");
765: rows[7].add(new Boolean(d.usesLocalFiles()));
766: // boolean usesLocalFiles() throws SQLException;
767: rows[8].add("usesLocalFilePerTable");
768: rows[8].add(new Boolean(d.usesLocalFilePerTable()));
769: // boolean usesLocalFilePerTable() throws SQLException;
770: rows[9].add("supportsMixedCaseIdentifiers");
771: rows[9].add(new Boolean(d.supportsMixedCaseIdentifiers()));
772: //boolean supportsMixedCaseIdentifiers() throws SQLException;
773: rows[10].add("storesUpperCaseIdentifiers");
774: rows[10].add(new Boolean(d.storesUpperCaseIdentifiers()));
775: // boolean storesUpperCaseIdentifiers() throws SQLException;
776: rows[11].add("storesLowerCaseIdentifiers");
777: rows[11].add(new Boolean(d.storesLowerCaseIdentifiers()));
778: // boolean storesLowerCaseIdentifiers() throws SQLException;
779: rows[12].add("storesMixedCaseIdentifiers");
780: rows[12].add(new Boolean(d.storesMixedCaseIdentifiers()));
781: // boolean storesMixedCaseIdentifiers() throws SQLException;
782: rows[13].add("supportsMixedCaseQuotedIdentifiers");
783: rows[13].add(new Boolean(d.supportsMixedCaseQuotedIdentifiers()));
784: // boolean supportsMixedCaseQuotedIdentifiers() throws SQLException;
785: rows[14].add("storesUpperCaseQuotedIdentifiers");
786: rows[14].add(new Boolean(d.storesUpperCaseQuotedIdentifiers()));
787: // boolean storesUpperCaseQuotedIdentifiers() throws SQLException;
788: rows[15].add("storesLowerCaseQuotedIdentifiers");
789: rows[15].add(new Boolean(d.storesLowerCaseQuotedIdentifiers()));
790: //boolean storesLowerCaseQuotedIdentifiers() throws SQLException;
791: rows[16].add("storesMixedCaseQuotedIdentifiers");
792: rows[16].add(new Boolean(d.storesMixedCaseQuotedIdentifiers()));
793: // boolean storesMixedCaseQuotedIdentifiers() throws SQLException;
794: rows[17].add("supportsAlterTableWithAddColumn");
795: rows[17].add(new Boolean(d.supportsAlterTableWithAddColumn()));
796: // boolean supportsAlterTableWithAddColumn() throws SQLException;
797: rows[18].add("supportsAlterTableWithDropColumn");
798: rows[18].add(new Boolean(d.supportsAlterTableWithDropColumn()));
799: // boolean supportsAlterTableWithDropColumn() throws SQLException;
800: rows[19].add("nullPlusNonNullIsNull");
801: rows[19].add(new Boolean(d.nullPlusNonNullIsNull()));
802: // boolean nullPlusNonNullIsNull() throws SQLException;
803: rows[20].add("supportsConvert");
804: rows[20].add(new Boolean(d.supportsConvert()));
805: // boolean supportsConvert() throws SQLException;
806:
807: // boolean supportsConvert(int fromType, int toType) throws SQLException;
808: rows[21].add("supportsTableCorrelationNames");
809: rows[21].add(new Boolean(d.supportsTableCorrelationNames()));
810: // boolean supportsTableCorrelationNames() throws SQLException;
811: rows[22].add("supportsDifferentTableCorrelationNames");
812: rows[22].add(new Boolean(d.supportsDifferentTableCorrelationNames()));
813: // boolean supportsDifferentTableCorrelationNames() throws SQLException;
814: rows[23].add("supportsExpressionsInOrderBy");
815: rows[23].add(new Boolean(d.supportsExpressionsInOrderBy()));
816: // boolean supportsExpressionsInOrderBy() throws SQLException;
817: rows[24].add("supportsOrderByUnrelated");
818: rows[24].add(new Boolean(d.supportsOrderByUnrelated()));
819: // boolean supportsOrderByUnrelated() throws SQLException;
820: rows[25].add("supportsGroupBy");
821: rows[25].add(new Boolean(d.supportsGroupBy()));
822: // boolean supportsGroupBy() throws SQLException;
823: rows[26].add("supportsGroupByUnrelated");
824: rows[26].add(new Boolean(d.supportsGroupByUnrelated()));
825: // boolean supportsGroupByUnrelated() throws SQLException;
826: rows[27].add("supportsGroupByBeyondSelect");
827: rows[27].add(new Boolean(d.supportsGroupByBeyondSelect()));
828: // boolean supportsGroupByBeyondSelect() throws SQLException;
829: rows[28].add("supportsLikeEscapeClause");
830: rows[28].add(new Boolean(d.supportsLikeEscapeClause()));
831: // boolean supportsLikeEscapeClause() throws SQLException;
832: rows[29].add("supportsMultipleResultSets");
833: rows[29].add(new Boolean(d.supportsMultipleResultSets()));
834: // boolean supportsMultipleResultSets() throws SQLException;
835: rows[30].add("supportsMultipleTransactions");
836: rows[30].add(new Boolean(d.supportsMultipleTransactions()));
837: // boolean supportsMultipleTransactions() throws SQLException;
838: rows[31].add("supportsNonNullableColumns");
839: rows[31].add(new Boolean(d.supportsNonNullableColumns()));
840: // boolean supportsNonNullableColumns() throws SQLException;
841: rows[32].add("supportsMinimumSQLGrammar");
842: rows[32].add(new Boolean(d.supportsMinimumSQLGrammar()));
843: // boolean supportsMinimumSQLGrammar() throws SQLException;
844: rows[33].add("supportsCoreSQLGrammar");
845: rows[33].add(new Boolean(d.supportsCoreSQLGrammar()));
846: // boolean supportsCoreSQLGrammar() throws SQLException;
847: rows[34].add("supportsExtendedSQLGrammar");
848: rows[34].add(new Boolean(d.supportsExtendedSQLGrammar()));
849: // boolean supportsExtendedSQLGrammar() throws SQLException;
850: rows[35].add("supportsANSI92EntryLevelSQL");
851: rows[35].add(new Boolean(d.supportsANSI92EntryLevelSQL()));
852: // boolean supportsANSI92EntryLevelSQL() throws SQLException;
853: rows[36].add("supportsANSI92IntermediateSQL");
854: rows[36].add(new Boolean(d.supportsANSI92IntermediateSQL()));
855: //boolean supportsANSI92IntermediateSQL() throws SQLException;
856: rows[37].add("supportsANSI92FullSQL");
857: rows[37].add(new Boolean(d.supportsANSI92FullSQL()));
858: //boolean supportsANSI92FullSQL() throws SQLException;
859: rows[38].add("supportsIntegrityEnhancementFacility");
860: rows[38].add(new Boolean(d.supportsIntegrityEnhancementFacility()));
861: //boolean supportsIntegrityEnhancementFacility() throws SQLException;
862: rows[39].add("supportsOuterJoins");
863: rows[39].add(new Boolean(d.supportsOuterJoins()));
864: //boolean supportsOuterJoins() throws SQLException;
865: rows[40].add("supportsFullOuterJoins");
866: rows[40].add(new Boolean(d.supportsFullOuterJoins()));
867: //boolean supportsFullOuterJoins() throws SQLException;
868: rows[41].add("supportsLimitedOuterJoins");
869: rows[41].add(new Boolean(d.supportsLimitedOuterJoins()));
870: //boolean supportsLimitedOuterJoins() throws SQLException;
871: rows[42].add("isCatalogAtStart");
872: rows[42].add(new Boolean(d.isCatalogAtStart()));
873: //boolean isCatalogAtStart() throws SQLException;
874: rows[43].add("supportsSchemasInDataManipulation");
875: rows[43].add(new Boolean(d.supportsSchemasInDataManipulation()));
876: //boolean supportsSchemasInDataManipulation() throws SQLException;
877: rows[44].add("supportsSchemasInProcedureCalls");
878: rows[44].add(new Boolean(d.supportsSchemasInProcedureCalls()));
879: //boolean supportsSchemasInProcedureCalls() throws SQLException;
880: rows[45].add("supportsSchemasInTableDefinitions");
881: rows[45].add(new Boolean(d.supportsSchemasInTableDefinitions()));
882: //boolean supportsSchemasInTableDefinitions() throws SQLException;
883: rows[46].add("supportsSchemasInIndexDefinitions");
884: rows[46].add(new Boolean(d.supportsSchemasInIndexDefinitions()));
885: //boolean supportsSchemasInIndexDefinitions() throws SQLException;
886: rows[47].add("supportsSchemasInPrivilegeDefinitions");
887: rows[47].add(new Boolean(d.supportsSchemasInPrivilegeDefinitions()));
888: //boolean supportsSchemasInPrivilegeDefinitions() throws SQLException;
889: rows[48].add("supportsCatalogsInDataManipulation");
890: rows[48].add(new Boolean(d.supportsCatalogsInDataManipulation()));
891: //boolean supportsCatalogsInDataManipulation() throws SQLException;
892: rows[49].add("supportsCatalogsInProcedureCalls");
893: rows[49].add(new Boolean(d.supportsCatalogsInProcedureCalls()));
894: //boolean supportsCatalogsInProcedureCalls() throws SQLException;
895: rows[50].add("supportsCatalogsInTableDefinitions");
896: rows[50].add(new Boolean(d.supportsCatalogsInTableDefinitions()));
897: //boolean supportsCatalogsInTableDefinitions() throws SQLException;
898: rows[51].add("supportsCatalogsInIndexDefinitions");
899: rows[51].add(new Boolean(d.supportsCatalogsInIndexDefinitions()));
900: //boolean supportsCatalogsInIndexDefinitions() throws SQLException;
901: rows[52].add("supportsCatalogsInPrivilegeDefinitions");
902: rows[52].add(new Boolean(d.supportsCatalogsInPrivilegeDefinitions()));
903: //boolean supportsCatalogsInPrivilegeDefinitions() throws SQLException;
904: rows[53].add("supportsPositionedDelete");
905: rows[53].add(new Boolean(d.supportsPositionedDelete()));
906: //boolean supportsPositionedDelete() throws SQLException;
907: rows[54].add("supportsPositionedUpdate");
908: rows[54].add(new Boolean(d.supportsPositionedUpdate()));
909: //boolean supportsPositionedUpdate() throws SQLException;
910: rows[55].add("supportsSelectForUpdate");
911: rows[55].add(new Boolean(d.supportsSelectForUpdate()));
912: //boolean supportsSelectForUpdate() throws SQLException;
913: rows[56].add("supportsStoredProcedures");
914: rows[56].add(new Boolean(d.supportsStoredProcedures()));
915: //boolean supportsStoredProcedures() throws SQLException;
916: rows[57].add("supportsSubqueriesInComparisons");
917: rows[57].add(new Boolean(d.supportsSubqueriesInComparisons()));
918: //boolean supportsSubqueriesInComparisons() throws SQLException;
919: rows[58].add("supportsSubqueriesInExists");
920: rows[58].add(new Boolean(d.supportsSubqueriesInExists()));
921: //boolean supportsSubqueriesInExists() throws SQLException;
922: rows[59].add("supportsSubqueriesInIns");
923: rows[59].add(new Boolean(d.supportsSubqueriesInIns()));
924: //boolean supportsSubqueriesInIns() throws SQLException;
925: rows[60].add("supportsSubqueriesInQuantifieds");
926: rows[60].add(new Boolean(d.supportsSubqueriesInQuantifieds()));
927: //boolean supportsSubqueriesInQuantifieds() throws SQLException;
928: rows[61].add("supportsCorrelatedSubqueries");
929: rows[61].add(new Boolean(d.supportsCorrelatedSubqueries()));
930: //boolean supportsCorrelatedSubqueries() throws SQLException;
931: rows[62].add("supportsUnion");
932: rows[62].add(new Boolean(d.supportsUnion()));
933: //boolean supportsUnion() throws SQLException;
934: rows[63].add("supportsUnionAll");
935: rows[63].add(new Boolean(d.supportsUnionAll()));
936: //boolean supportsUnionAll() throws SQLException;
937: rows[64].add("supportsOpenCursorsAcrossCommit");
938: rows[64].add(new Boolean(d.supportsOpenCursorsAcrossCommit()));
939: //boolean supportsOpenCursorsAcrossCommit() throws SQLException;
940: rows[65].add("supportsOpenCursorsAcrossRollback");
941: rows[65].add(new Boolean(d.supportsOpenCursorsAcrossRollback()));
942: //boolean supportsOpenCursorsAcrossRollback() throws SQLException;
943: rows[66].add("supportsOpenStatementsAcrossCommit");
944: rows[66].add(new Boolean(d.supportsOpenStatementsAcrossCommit()));
945: //boolean supportsOpenStatementsAcrossCommit() throws SQLException;
946: rows[67].add("supportsOpenStatementsAcrossRollback");
947: rows[67].add(new Boolean(d.supportsOpenStatementsAcrossRollback()));
948: //boolean supportsOpenStatementsAcrossRollback() throws SQLException;
949: rows[68].add("doesMaxRowSizeIncludeBlobs");
950: rows[68].add(new Boolean(d.doesMaxRowSizeIncludeBlobs()));
951: //boolean doesMaxRowSizeIncludeBlobs() throws SQLException;
952: rows[69].add("supportsTransactions");
953: rows[69].add(new Boolean(d.supportsTransactions()));
954: //boolean supportsTransactions() throws SQLException;
955: rows[70].add("supportsTransactionIsolationLevel");
956: rows[70].add(new Boolean(d.supportsTransactionIsolationLevel(1)));
957: //boolean supportsTransactionIsolationLevel(int level) throws SQLException;
958: rows[71].add("supportsDataDefinitionAndDataManipulationTransactions");
959: rows[71].add(new Boolean(d.supportsDataDefinitionAndDataManipulationTransactions()));
960: //boolean supportsDataDefinitionAndDataManipulationTransactions() throws SQLException;
961: rows[72].add("supportsDataManipulationTransactionsOnly");
962: rows[72].add(new Boolean(d.supportsDataManipulationTransactionsOnly()));
963: //boolean supportsDataManipulationTransactionsOnly() throws SQLException;
964: rows[73].add("dataDefinitionCausesTransactionCommit");
965: rows[73].add(new Boolean(d.dataDefinitionCausesTransactionCommit()));
966: //boolean dataDefinitionCausesTransactionCommit() throws SQLException;
967: rows[74].add("dataDefinitionIgnoredInTransactions");
968: rows[74].add(new Boolean(d.dataDefinitionIgnoredInTransactions()));
969: //boolean dataDefinitionIgnoredInTransactions() throws SQLException;
970: rows[75].add("getMaxBinaryLiteralLength");
971: rows[75].add(new Integer(d.getMaxBinaryLiteralLength()));
972: // int getMaxBinaryLiteralLength() throws SQLException;
973: rows[76].add("getMaxCharLiteralLength");
974: rows[76].add(new Integer(d.getMaxCharLiteralLength()));
975: //int getMaxCharLiteralLength() throws SQLException;
976: rows[77].add("getMaxColumnNameLength");
977: rows[77].add(new Integer(d.getMaxColumnNameLength()));
978: // int getMaxColumnNameLength() throws SQLException;
979: rows[78].add("getMaxColumnsInGroupBy");
980: rows[78].add(new Integer(d.getMaxColumnsInGroupBy()));
981: //int getMaxColumnsInGroupBy() throws SQLException;
982: rows[79].add("getMaxColumnsInIndex");
983: rows[79].add(new Integer(d.getMaxColumnsInIndex()));
984: //int getMaxColumnsInIndex() throws SQLException;
985: rows[80].add("getMaxColumnsInOrderBy");
986: rows[80].add(new Integer(d.getMaxColumnsInOrderBy()));
987: //int getMaxColumnsInOrderBy() throws SQLException;
988: rows[81].add("getMaxColumnsInSelect");
989: rows[81].add(new Integer(d.getMaxColumnsInSelect()));
990: //int getMaxColumnsInSelect() throws SQLException;
991: rows[82].add("getMaxColumnsInTable");
992: rows[82].add(new Integer(d.getMaxColumnsInTable()));
993: //int getMaxColumnsInTable() throws SQLException;
994: rows[83].add("getMaxConnections");
995: rows[83].add(new Integer(d.getMaxConnections()));
996: //int getMaxConnections() throws SQLException;
997: rows[84].add("getMaxCursorNameLength");
998: rows[84].add(new Integer(d.getMaxCursorNameLength()));
999: // int getMaxCursorNameLength() throws SQLException;
1000: rows[85].add("getMaxIndexLength");
1001: rows[85].add(new Integer(d.getMaxIndexLength()));
1002: //int getMaxIndexLength() throws SQLException;
1003: rows[86].add("getMaxSchemaNameLength");
1004: rows[86].add(new Integer(d.getMaxSchemaNameLength()));
1005: //int getMaxSchemaNameLength() throws SQLException;
1006: rows[87].add("getMaxProcedureNameLength");
1007: rows[87].add(new Integer(d.getMaxProcedureNameLength()));
1008: //int getMaxProcedureNameLength() throws SQLException;
1009: rows[88].add("getMaxCatalogNameLength");
1010: rows[88].add(new Integer(d.getMaxCatalogNameLength()));
1011: //int getMaxCatalogNameLength() throws SQLException;
1012: rows[89].add("getMaxRowSize");
1013: rows[89].add(new Integer(d.getMaxRowSize()));
1014: //int getMaxRowSize() throws SQLException;
1015: rows[90].add("getMaxStatementLength");
1016: rows[90].add(new Integer(d.getMaxStatementLength()));
1017: //int getMaxStatementLength() throws SQLException;
1018: rows[91].add("getMaxStatements");
1019: rows[91].add(new Integer(d.getMaxStatements()));
1020: //int getMaxStatements() throws SQLException;
1021: rows[92].add("getMaxTableNameLength");
1022: rows[92].add(new Integer(d.getMaxTableNameLength()));
1023: //int getMaxTableNameLength() throws SQLException;
1024: rows[93].add("getMaxTablesInSelect");
1025: rows[93].add(new Integer(d.getMaxTablesInSelect()));
1026: //int getMaxTablesInSelect() throws SQLException;
1027: rows[94].add("getMaxUserNameLength");
1028: rows[94].add(new Integer(d.getMaxUserNameLength()));
1029: // int getMaxUserNameLength() throws SQLException;
1030: rows[95].add("getDefaultTransactionIsolation");
1031: rows[95].add(new Integer(d.getDefaultTransactionIsolation()));
1032: //int getDefaultTransactionIsolation() throws SQLException;
1033:
1034: rows[96].add("getDatabaseProductName");
1035: rows[96].add(d.getDatabaseProductName());
1036: // String getDatabaseProductName() throws SQLException;
1037: rows[97].add("getDatabaseProductVersion");
1038: rows[97].add(d.getDatabaseProductVersion());
1039: //String getDatabaseProductVersion() throws SQLException;
1040:
1041: rows[98].add("getURL");
1042: rows[98].add(d.getURL());
1043: //String getURL() throws SQLException;
1044: rows[99].add("getUserName");
1045: rows[99].add(d.getUserName());
1046: //String getUserName() throws SQLException;
1047: rows[100].add("getDriverName");
1048: rows[100].add(d.getDriverName());
1049: // String getDriverName() throws SQLException;
1050: rows[101].add("getIdentifierQuoteString");
1051: rows[101].add(d.getIdentifierQuoteString());
1052: //String getIdentifierQuoteString() throws SQLException;
1053:
1054: rows[102].add("getDriverVersion");
1055: rows[102].add(d.getDriverVersion());
1056: //String getDriverVersion() throws SQLException;
1057: rows[103].add("getDriverMajorVersion");
1058: rows[103].add(new Integer(d.getDriverMajorVersion()));
1059: //int getDriverMajorVersion();
1060: rows[104].add("getDriverMinorVersion");
1061: rows[104].add(new Integer(d.getDriverMinorVersion()));
1062: //int getDriverMinorVersion();
1063: rows[105].add("getSQLKeywords");
1064: rows[105].add(d.getSQLKeywords());
1065: //String getSQLKeywords() throws SQLException;
1066: rows[106].add("getNumericFunctions");
1067: rows[106].add(d.getNumericFunctions());
1068: //String getNumericFunctions() throws SQLException;
1069: rows[107].add("getStringFunctions");
1070: rows[107].add(d.getStringFunctions());
1071: // String getStringFunctions() throws SQLException;
1072: rows[108].add("getSystemFunctions");
1073: rows[108].add(d.getSystemFunctions());
1074: //String getSystemFunctions() throws SQLException;
1075: rows[109].add("getTimeDateFunctions");
1076: rows[109].add(d.getTimeDateFunctions());
1077: //String getTimeDateFunctions() throws SQLException;
1078: rows[110].add("getSearchStringEscape");
1079: rows[110].add(d.getSearchStringEscape());
1080: //String getSearchStringEscape() throws SQLException;
1081: rows[111].add("getExtraNameCharacters");
1082: rows[111].add(d.getExtraNameCharacters());
1083: //String getExtraNameCharacters() throws SQLException;
1084: rows[112].add("getSchemaTerm");
1085: rows[112].add(d.getSchemaTerm());
1086: //String getSchemaTerm() throws SQLException;
1087: rows[113].add("getProcedureTerm");
1088: rows[113].add(d.getProcedureTerm());
1089: //String getProcedureTerm() throws SQLException;
1090: rows[114].add("getCatalogTerm");
1091: rows[114].add(d.getCatalogTerm());
1092: // String getCatalogTerm() throws SQLException;
1093: rows[115].add("getCatalogSeparator");
1094: rows[115].add(d.getCatalogSeparator());
1095: //String getCatalogSeparator() throws SQLException;
1096:
1097: /*
1098: boolean supportsResultSetType(int type) throws SQLException;
1099:
1100: boolean supportsResultSetConcurrency(int type, int concurrency) throws SQLException;
1101:
1102: boolean ownUpdatesAreVisible(int type) throws SQLException;
1103:
1104: boolean ownDeletesAreVisible(int type) throws SQLException;
1105:
1106: boolean ownInsertsAreVisible(int type) throws SQLException;
1107:
1108: boolean othersUpdatesAreVisible(int type) throws SQLException;
1109:
1110: boolean othersDeletesAreVisible(int type) throws SQLException;
1111:
1112: boolean othersInsertsAreVisible(int type) throws SQLException;
1113: boolean updatesAreDetected(int type) throws SQLException;
1114: boolean deletesAreDetected(int type) throws SQLException;
1115:
1116: boolean insertsAreDetected(int type) throws SQLException;
1117: */
1118: // not in filemaker
1119: // rows[96].add("supportsBatchUpdates");
1120: // rows[96].add(new Boolean(d.supportsBatchUpdates()));
1121: //boolean supportsBatchUpdates() throws SQLException;
1122:
1123: /*
1124: ResultSet getProcedures(String catalog, String schemaPattern, String procedureNamePattern) throws SQLException;
1125:
1126: ResultSet getProcedureColumns(String catalog, String schemaPattern, String procedureNamePattern, String columnNamePattern) throws SQLException;
1127: ResultSet getTables(String catalog, String schemaPattern, String tableNamePattern, String types[]) throws SQLException;
1128: ResultSet getSchemas() throws SQLException;
1129: ResultSet getCatalogs() throws SQLException;
1130: ResultSet getTableTypes() throws SQLException;
1131: ResultSet getColumns(String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern) throws SQLException;
1132: ResultSet getPrimaryKeys(String catalog, String schema, String table) throws SQLException;
1133: ResultSet getImportedKeys(String catalog, String schema, String table) throws SQLException;
1134: ResultSet getExportedKeys(String catalog, String schema, String table) throws SQLException;
1135: ResultSet getCrossReference(String primaryCatalog, String primarySchema, String primaryTable, String foreignCatalog, String foreignSchema, String foreignTable) throws SQLException;
1136: ResultSet getTypeInfo() throws SQLException;
1137: ResultSet getIndexInfo(String catalog, String schema, String table, boolean unique, boolean approximate) throws SQLException;
1138:
1139: ResultSet getUDTs(String catalog, String schemaPattern, String typeNamePattern, int[] types) throws SQLException;
1140:
1141: Connection getConnection() throws SQLException;
1142:
1143: */
1144: for (int i = 0; i < rows.length; ++i)
1145: cols.add(rows[i]);
1146: data[0] = cols;
1147: data[1] = columnNames;
1148: return data;
1149: }
1150: public Vector getNextRow() throws Exception
1151: {
1152:
1153: if (result == null)
1154: return null;
1155: boolean check = false;
1156: ResultSet resultSet = result;
1157: ResultSetMetaData metaData = resultSet.getMetaData();
1158: int columnCount = metaData.getColumnCount();
1159: Vector tableData = new Vector();
1160: check = resultSet.next();
1161: // System.out.println("hallo check "+check);
1162: if (!check)
1163: return null;
1164: Vector tableRow = new Vector(), m_columnClasses = new Vector();
1165: for (int i = 1; i <= columnCount; i++)
1166: {
1167: // repeating fields and fields from related databases may contain
1168: // multliple data values; the data values are stored using
1169: // a Vector which is then added to the tableRow
1170: // if (metaData instanceof ResultSetMetaDataExt)
1171: if ((metaData instanceof ResultSetMetaDataExt) && (((ResultSetMetaDataExt) metaData).isRelated(i) || ((ResultSetMetaDataExt) metaData).isRepeating(i)))
1172: {
1173: //System.out.println("Related fields");
1174: // retrieve the repeating or related field contents as a
1175: // com.fmi.jdbc.Array via the ResultSet.getObject method
1176: com.fmi.jdbc.Array array = (com.fmi.jdbc.Array) resultSet.getObject(i);
1177: // create a Vector for storing all of the data values
1178: ArrayList columnData = new ArrayList();
1179: try
1180: {
1181:
1182: // call the Array.getStringArray method since the data will
1183: // only be displayed
1184: Object[] fieldData = (Object[]) array.getArray();
1185:
1186: if (fieldData != null)
1187: {
1188: // add each value to the Vector
1189: for (int j = 0; j < fieldData.length; j++)
1190: {
1191: if (fieldData[j] != null)
1192: columnData.add(fieldData[j]);
1193: }
1194: }
1195: } catch (Exception e)
1196: {
1197: //System.out.println(e);
1198: }
1199:
1200: if (columnData.isEmpty())
1201: tableRow.add(null);
1202: else
1203: tableRow.addElement(columnData);
1204: //System.out.println(columnData);
1205: //System.out.println("Related fields"+columnData.size()+" "+tableRow.size());
1206:
1207: // m_columnClasses.addElement(java.util.Vector.class);
1208: } else if (metaData.getColumnType(i) == Types.LONGVARBINARY)
1209: {
1210: // use the ResultSet.getObject method for retrieving images
1211: // from FileMaker Pro container fields; the ResultSet.getObject
1212: // method returns a java.awt.Image object for FileMaker Pro
1213: // container fields
1214:
1215: try
1216: {
1217: tableRow.addElement(resultSet.getObject(i));
1218: } catch (Exception e)
1219: {
1220: // TODO Auto-generated catch block
1221: // e.printStackTrace();
1222: tableRow.addElement(null);
1223: }
1224: // m_columnClasses.addElement(java.awt.Image.class);
1225: } else if (metaData.getColumnType(i) == Types.TIME)
1226: {
1227: // use the ResultSet.getObject method for retieving images
1228: // from FileMaker Pro container fields; the ResultSet.getObject
1229: // method returns a java.awt.Image object for FileMaker Pro
1230: // container fields
1231: try
1232: {
1233: tableRow.addElement(resultSet.getTime(i).toString());
1234: // m_columnClasses.addElement(java.sql.Time.class);
1235: } catch (Exception e)
1236: {
1237:
1238: String value = resultSet.getString(i);
1239: if (value != null)
1240: {
1241: //System.out.println("SQLTime new "+Time.valueOf("17:00:00").toString());
1242: int index = 0;
1243: for (int j = 0; j < value.length(); ++j)
1244: {
1245: if (!Character.isLetter(value.charAt(j)))
1246: index = j + 1;
1247: else
1248: break;
1249: }
1250:
1251: tableRow.addElement(value.substring(0, index));
1252: //m_columnClasses.addElement(java.sql.Time.class);
1253: } else
1254: tableRow.add(null);
1255: // m_columnClasses.addElement(String.class);
1256: } // to catch
1257:
1.10 rogo 1258: } else if (metaData.getColumnType(i) == Types.INTEGER)
1259: {
1260: // use the ResultSet.getObject method for retieving images
1261: // from FileMaker Pro container fields; the ResultSet.getObject
1262: // method returns a java.awt.Image object for FileMaker Pro
1263: // container fields
1264:
1265: tableRow.addElement(new Integer(resultSet.getInt(i)));
1266: // m_columnClasses.addElement(java.sql.Date.class);
1267: } else if (metaData.getColumnType(i) == Types.DATE)
1268: {
1.1 rogo 1269: // use the ResultSet.getObject method for retieving images
1270: // from FileMaker Pro container fields; the ResultSet.getObject
1271: // method returns a java.awt.Image object for FileMaker Pro
1272: // container fields
1.14 rogo 1273: try
1274: {
1275: tableRow.addElement(resultSet.getDate(i));
1.1 rogo 1276:
1.14 rogo 1277: } catch (Exception e)
1278: {
1.15 rogo 1279: // work around for parse bug in FM JDBC Driver
1280: // for dates of format dd-mm-yyyy
1.14 rogo 1281: String date=resultSet.getString(i);
1.15 rogo 1282: date=date.replace('-','.');
1283: java.text.DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.SHORT,Locale.GERMAN);
1284: java.util.Date d= dateFormat.parse(date);
1.16 ! rogo 1285: // Calendar cal=Calendar.getInstance(Locale.GERMAN);
! 1286: // cal.setTime(d);
! 1287: // date=(cal.get(Calendar.YEAR))+"-"+(cal.get(Calendar.MONTH)+1)+"-"+cal.get(Calendar.DATE);
! 1288: tableRow.addElement(new java.sql.Date(d.getTime()));
! 1289: System.out.println("Date "+date);
1.14 rogo 1290: }
1.1 rogo 1291: // m_columnClasses.addElement(java.sql.Date.class);
1292: } else if (metaData.getColumnTypeName(i) == "NUMBER")
1293: {
1294: // use the ResultSet.getObject method for retieving images
1295: // from FileMaker Pro container fields; the ResultSet.getObject
1296: // method returns a java.awt.Image object for FileMaker Pro
1297: // container fields
1298: try
1299: {
1.13 rogo 1300: tableRow.addElement(new Double(resultSet.getDouble(i)));
1.1 rogo 1301: // m_columnClasses.addElement(Integer.class);
1302:
1303: } catch (Exception e)
1304: {
1305:
1306: StringBuffer number = new StringBuffer();
1307: String value = resultSet.getString(i);
1308: System.out.println(value);
1309: for (int c = 0; c < value.length(); ++c)
1310: {
1311: if (Character.isDigit(value.charAt(c)))
1312: {
1313: number.append(value.charAt(c));
1314: }
1315: }
1316: if (number.length() > 0)
1317: {
1318: tableRow.addElement(null);
1319: // m_columnClasses.addElement(Integer.class);
1320: } else
1321: tableRow.addElement(null);
1322: }
1323: } else
1324: {
1325: // all other field values are retrieved as strings and
1326: // added to the tableRow Vector
1327: // System.out.println("row "+resultSet.getString(i));
1328: try
1329: {
1330: byte[] b = null;
1331: if (metaData instanceof ResultSetMetaDataExt)
1332: b = resultSet.getBytes(i);
1333: String utf8 = null;
1334: utf8 = (b == null) ? null : new String(b);
1335: if (metaData instanceof ResultSetMetaDataExt)
1336: tableRow.addElement((b != null) ? new String(utf8.getBytes()) : null);
1337: else
1338: {
1339: // byte[] val = resultSet.getBytes(i);
1340: tableRow.add(resultSet.getString(i));
1341: //tableRow.addElement((val==null) ? null:new String(val,"UTF-8"));
1342: }
1343: } catch (Exception e)
1344: {
1345: System.out.println("Hey I Got an error" + e);
1346: e.printStackTrace();
1347: }
1348: // m_columnClasses.addElement(java.lang.String.class);
1349: }
1350: }
1351: // tableData.addElement(tableRow);
1352: if (check)
1353: return tableRow;
1354: else
1355: return null;
1356: }
1357: class ConnectionPool
1358: {
1359: String user = "", passwd = "", url = "";
1360: Connection con;
1361: public ConnectionPool(String url, String user, String passwd, Connection con)
1362: {
1363: this.con = con;
1364: this.user = user;
1365: this.passwd = passwd;
1366: this.url = url;
1367: }
1368:
1369: }
1370: public String getQC()
1371: {
1372: // if (connection == null)
1373: // return "";
1374:
1375: // check if connection null if null try to get one
1376: if (connection == null)
1377: try
1378: {
1379: getConnection();
1380: } catch (Exception e)
1381: {
1382: if (FM2SQL.debug)
1383: System.out.println("cannot get a connection");
1384: }
1385: if (connection == null)
1386: {
1387: if (url.toLowerCase().indexOf("fmpro") >= 0 || url.toLowerCase().indexOf("postgres") >= 0)
1388: quoteChar = "\"";
1389: else if (url.toLowerCase().indexOf("mysql") >= 0)
1390: quoteChar = "`";
1391: }
1392: if (quoteChar == null)
1393: quoteChar = "\""; // needed for postgres
1394: return quoteChar;
1395: }
1396: public int getRowCount(String query) throws SQLException
1397: {
1398: String table = query.substring(query.indexOf("from") + 4).trim();
1399: int index = table.indexOf(" ");
1400: table = table.substring(0, (index >= 0) ? index : table.length());
1401: System.out.println(table);
1402: Statement stm = null;
1403:
1404: if (metaData instanceof ResultSetMetaDataExt)
1405: return 1000;
1406: if (!connection.isClosed())
1407: stm = connection.createStatement();
1408: stm.setMaxRows(1);
1409: ResultSet resultSet = stm.executeQuery("select count(*) from " + table);
1410: resultSet.next();
1411: return resultSet.getInt(1);
1412: }
1.8 rogo 1413: public TreeSet getIDVector(String id,String table,String query,int numHits) throws Exception
1.5 rogo 1414: {
1415: TreeSet t= new TreeSet();
1416: getConnection();
1417: ResultSet result = this.result;
1.7 rogo 1418: String subQuery = query.substring(query.lastIndexOf(table)+table.length()+1);
1419: System.out.println("subQuery "+subQuery);
1.8 rogo 1420: makeQuery("select "+id+" from "+getQC()+table+getQC()+subQuery,numHits );
1.5 rogo 1421: while(true)
1422: {
1.6 rogo 1423: Vector vec = getNextRow();
1424: if (vec == null)
1425: break;
1426: t.add(vec.get(0));
1.5 rogo 1427: }
1428: this.result=result;
1.10 rogo 1429: metaData = (this.result==null) ?null:this.result.getMetaData();
1.6 rogo 1430: return t;
1.5 rogo 1431: }
1432:
1433: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>