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