Annotation of FM2SQL/DBBean.java, revision 1.11
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: {
572: tableRow.addElement(new Integer(resultSet.getInt(i)));
573: m_columnClasses.addElement(Integer.class);
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);
591: m_columnClasses.addElement(Integer.class);
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();
668: stm.setMaxRows(numberOfHits);
1.2 rogo 669: long time = System.currentTimeMillis();
670: stm.execute(query);
671: long time2 = System.currentTimeMillis();
672:
673: System.out.println("time to execute "+(time2-time));
674: // stm.setMaxRows(numberOfHits);
675:
676: result = stm.getResultSet();
677: // System.out.println(result+" "+stm.getUpdateCount());
1.1 rogo 678: metaData = result.getMetaData();
679: return result;
680: }
681: /**
682: * sets the database user
683: */
684: public void setUser(String user)
685: {
686: this.user = user;
687: }
688: /**
689: * sets the database passwd
690: */
691: public void setPasswd(String passwd)
692: {
693: this.passwd = passwd;
694: }
695:
696: /**
697: * sets the database user and passwd
698: */
699: public void setUserAndPasswd(String user, String passwd)
700: {
701: this.user = user;
702: this.passwd = passwd;
703:
704: }
705: /**
706: * just sets the connection URL
707: */
708: public void setURL(String url)
709: {
710: this.url = url;
711: }
712:
713: /**
714: * Test the database drivers features given by the DatabaseMetaData object
715: */
716: public Vector[] TestDB(DatabaseMetaData d) throws SQLException
717: {
718:
719: Vector data[] = new Vector[2];
720: Vector[] rows = new Vector[120];
721: for (int i = 0; i < rows.length; ++i)
722: rows[i] = new Vector();
723: Vector columnNames = new Vector();
724: columnNames.add("Feature");
725: columnNames.add("Supported");
726:
727: Vector cols = new Vector();
728: rows[0].add("allProceduresAreCallable");
729: rows[0].add(new Boolean(d.allProceduresAreCallable()));
730: //boolean allProceduresAreCallable() throws SQLException;
731: rows[1].add("allTablesAreSelectable");
732: rows[1].add(new Boolean(d.allTablesAreSelectable()));
733: // boolean allTablesAreSelectable() throws SQLException;
734: rows[2].add("isReadOnly");
735: rows[2].add(new Boolean(d.isReadOnly()));
736: // boolean isReadOnly() throws SQLException;
737: rows[3].add("nullsAreSortedHigh");
738: rows[3].add(new Boolean(d.nullsAreSortedHigh()));
739: // boolean nullsAreSortedHigh() throws SQLException;
740: rows[4].add("nullsAreSortedLow");
741: rows[4].add(new Boolean(d.nullsAreSortedLow()));
742: // boolean nullsAreSortedLow() throws SQLException;
743: rows[5].add("nullsAreSortedAtStart");
744: rows[5].add(new Boolean(d.nullsAreSortedAtStart()));
745: // boolean nullsAreSortedAtStart() throws SQLException;
746: rows[6].add("nullsAreSortedAtEnd");
747: rows[6].add(new Boolean(d.nullsAreSortedAtEnd()));
748: // boolean nullsAreSortedAtEnd() throws SQLException;
749: rows[7].add("usesLocalFiles");
750: rows[7].add(new Boolean(d.usesLocalFiles()));
751: // boolean usesLocalFiles() throws SQLException;
752: rows[8].add("usesLocalFilePerTable");
753: rows[8].add(new Boolean(d.usesLocalFilePerTable()));
754: // boolean usesLocalFilePerTable() throws SQLException;
755: rows[9].add("supportsMixedCaseIdentifiers");
756: rows[9].add(new Boolean(d.supportsMixedCaseIdentifiers()));
757: //boolean supportsMixedCaseIdentifiers() throws SQLException;
758: rows[10].add("storesUpperCaseIdentifiers");
759: rows[10].add(new Boolean(d.storesUpperCaseIdentifiers()));
760: // boolean storesUpperCaseIdentifiers() throws SQLException;
761: rows[11].add("storesLowerCaseIdentifiers");
762: rows[11].add(new Boolean(d.storesLowerCaseIdentifiers()));
763: // boolean storesLowerCaseIdentifiers() throws SQLException;
764: rows[12].add("storesMixedCaseIdentifiers");
765: rows[12].add(new Boolean(d.storesMixedCaseIdentifiers()));
766: // boolean storesMixedCaseIdentifiers() throws SQLException;
767: rows[13].add("supportsMixedCaseQuotedIdentifiers");
768: rows[13].add(new Boolean(d.supportsMixedCaseQuotedIdentifiers()));
769: // boolean supportsMixedCaseQuotedIdentifiers() throws SQLException;
770: rows[14].add("storesUpperCaseQuotedIdentifiers");
771: rows[14].add(new Boolean(d.storesUpperCaseQuotedIdentifiers()));
772: // boolean storesUpperCaseQuotedIdentifiers() throws SQLException;
773: rows[15].add("storesLowerCaseQuotedIdentifiers");
774: rows[15].add(new Boolean(d.storesLowerCaseQuotedIdentifiers()));
775: //boolean storesLowerCaseQuotedIdentifiers() throws SQLException;
776: rows[16].add("storesMixedCaseQuotedIdentifiers");
777: rows[16].add(new Boolean(d.storesMixedCaseQuotedIdentifiers()));
778: // boolean storesMixedCaseQuotedIdentifiers() throws SQLException;
779: rows[17].add("supportsAlterTableWithAddColumn");
780: rows[17].add(new Boolean(d.supportsAlterTableWithAddColumn()));
781: // boolean supportsAlterTableWithAddColumn() throws SQLException;
782: rows[18].add("supportsAlterTableWithDropColumn");
783: rows[18].add(new Boolean(d.supportsAlterTableWithDropColumn()));
784: // boolean supportsAlterTableWithDropColumn() throws SQLException;
785: rows[19].add("nullPlusNonNullIsNull");
786: rows[19].add(new Boolean(d.nullPlusNonNullIsNull()));
787: // boolean nullPlusNonNullIsNull() throws SQLException;
788: rows[20].add("supportsConvert");
789: rows[20].add(new Boolean(d.supportsConvert()));
790: // boolean supportsConvert() throws SQLException;
791:
792: // boolean supportsConvert(int fromType, int toType) throws SQLException;
793: rows[21].add("supportsTableCorrelationNames");
794: rows[21].add(new Boolean(d.supportsTableCorrelationNames()));
795: // boolean supportsTableCorrelationNames() throws SQLException;
796: rows[22].add("supportsDifferentTableCorrelationNames");
797: rows[22].add(new Boolean(d.supportsDifferentTableCorrelationNames()));
798: // boolean supportsDifferentTableCorrelationNames() throws SQLException;
799: rows[23].add("supportsExpressionsInOrderBy");
800: rows[23].add(new Boolean(d.supportsExpressionsInOrderBy()));
801: // boolean supportsExpressionsInOrderBy() throws SQLException;
802: rows[24].add("supportsOrderByUnrelated");
803: rows[24].add(new Boolean(d.supportsOrderByUnrelated()));
804: // boolean supportsOrderByUnrelated() throws SQLException;
805: rows[25].add("supportsGroupBy");
806: rows[25].add(new Boolean(d.supportsGroupBy()));
807: // boolean supportsGroupBy() throws SQLException;
808: rows[26].add("supportsGroupByUnrelated");
809: rows[26].add(new Boolean(d.supportsGroupByUnrelated()));
810: // boolean supportsGroupByUnrelated() throws SQLException;
811: rows[27].add("supportsGroupByBeyondSelect");
812: rows[27].add(new Boolean(d.supportsGroupByBeyondSelect()));
813: // boolean supportsGroupByBeyondSelect() throws SQLException;
814: rows[28].add("supportsLikeEscapeClause");
815: rows[28].add(new Boolean(d.supportsLikeEscapeClause()));
816: // boolean supportsLikeEscapeClause() throws SQLException;
817: rows[29].add("supportsMultipleResultSets");
818: rows[29].add(new Boolean(d.supportsMultipleResultSets()));
819: // boolean supportsMultipleResultSets() throws SQLException;
820: rows[30].add("supportsMultipleTransactions");
821: rows[30].add(new Boolean(d.supportsMultipleTransactions()));
822: // boolean supportsMultipleTransactions() throws SQLException;
823: rows[31].add("supportsNonNullableColumns");
824: rows[31].add(new Boolean(d.supportsNonNullableColumns()));
825: // boolean supportsNonNullableColumns() throws SQLException;
826: rows[32].add("supportsMinimumSQLGrammar");
827: rows[32].add(new Boolean(d.supportsMinimumSQLGrammar()));
828: // boolean supportsMinimumSQLGrammar() throws SQLException;
829: rows[33].add("supportsCoreSQLGrammar");
830: rows[33].add(new Boolean(d.supportsCoreSQLGrammar()));
831: // boolean supportsCoreSQLGrammar() throws SQLException;
832: rows[34].add("supportsExtendedSQLGrammar");
833: rows[34].add(new Boolean(d.supportsExtendedSQLGrammar()));
834: // boolean supportsExtendedSQLGrammar() throws SQLException;
835: rows[35].add("supportsANSI92EntryLevelSQL");
836: rows[35].add(new Boolean(d.supportsANSI92EntryLevelSQL()));
837: // boolean supportsANSI92EntryLevelSQL() throws SQLException;
838: rows[36].add("supportsANSI92IntermediateSQL");
839: rows[36].add(new Boolean(d.supportsANSI92IntermediateSQL()));
840: //boolean supportsANSI92IntermediateSQL() throws SQLException;
841: rows[37].add("supportsANSI92FullSQL");
842: rows[37].add(new Boolean(d.supportsANSI92FullSQL()));
843: //boolean supportsANSI92FullSQL() throws SQLException;
844: rows[38].add("supportsIntegrityEnhancementFacility");
845: rows[38].add(new Boolean(d.supportsIntegrityEnhancementFacility()));
846: //boolean supportsIntegrityEnhancementFacility() throws SQLException;
847: rows[39].add("supportsOuterJoins");
848: rows[39].add(new Boolean(d.supportsOuterJoins()));
849: //boolean supportsOuterJoins() throws SQLException;
850: rows[40].add("supportsFullOuterJoins");
851: rows[40].add(new Boolean(d.supportsFullOuterJoins()));
852: //boolean supportsFullOuterJoins() throws SQLException;
853: rows[41].add("supportsLimitedOuterJoins");
854: rows[41].add(new Boolean(d.supportsLimitedOuterJoins()));
855: //boolean supportsLimitedOuterJoins() throws SQLException;
856: rows[42].add("isCatalogAtStart");
857: rows[42].add(new Boolean(d.isCatalogAtStart()));
858: //boolean isCatalogAtStart() throws SQLException;
859: rows[43].add("supportsSchemasInDataManipulation");
860: rows[43].add(new Boolean(d.supportsSchemasInDataManipulation()));
861: //boolean supportsSchemasInDataManipulation() throws SQLException;
862: rows[44].add("supportsSchemasInProcedureCalls");
863: rows[44].add(new Boolean(d.supportsSchemasInProcedureCalls()));
864: //boolean supportsSchemasInProcedureCalls() throws SQLException;
865: rows[45].add("supportsSchemasInTableDefinitions");
866: rows[45].add(new Boolean(d.supportsSchemasInTableDefinitions()));
867: //boolean supportsSchemasInTableDefinitions() throws SQLException;
868: rows[46].add("supportsSchemasInIndexDefinitions");
869: rows[46].add(new Boolean(d.supportsSchemasInIndexDefinitions()));
870: //boolean supportsSchemasInIndexDefinitions() throws SQLException;
871: rows[47].add("supportsSchemasInPrivilegeDefinitions");
872: rows[47].add(new Boolean(d.supportsSchemasInPrivilegeDefinitions()));
873: //boolean supportsSchemasInPrivilegeDefinitions() throws SQLException;
874: rows[48].add("supportsCatalogsInDataManipulation");
875: rows[48].add(new Boolean(d.supportsCatalogsInDataManipulation()));
876: //boolean supportsCatalogsInDataManipulation() throws SQLException;
877: rows[49].add("supportsCatalogsInProcedureCalls");
878: rows[49].add(new Boolean(d.supportsCatalogsInProcedureCalls()));
879: //boolean supportsCatalogsInProcedureCalls() throws SQLException;
880: rows[50].add("supportsCatalogsInTableDefinitions");
881: rows[50].add(new Boolean(d.supportsCatalogsInTableDefinitions()));
882: //boolean supportsCatalogsInTableDefinitions() throws SQLException;
883: rows[51].add("supportsCatalogsInIndexDefinitions");
884: rows[51].add(new Boolean(d.supportsCatalogsInIndexDefinitions()));
885: //boolean supportsCatalogsInIndexDefinitions() throws SQLException;
886: rows[52].add("supportsCatalogsInPrivilegeDefinitions");
887: rows[52].add(new Boolean(d.supportsCatalogsInPrivilegeDefinitions()));
888: //boolean supportsCatalogsInPrivilegeDefinitions() throws SQLException;
889: rows[53].add("supportsPositionedDelete");
890: rows[53].add(new Boolean(d.supportsPositionedDelete()));
891: //boolean supportsPositionedDelete() throws SQLException;
892: rows[54].add("supportsPositionedUpdate");
893: rows[54].add(new Boolean(d.supportsPositionedUpdate()));
894: //boolean supportsPositionedUpdate() throws SQLException;
895: rows[55].add("supportsSelectForUpdate");
896: rows[55].add(new Boolean(d.supportsSelectForUpdate()));
897: //boolean supportsSelectForUpdate() throws SQLException;
898: rows[56].add("supportsStoredProcedures");
899: rows[56].add(new Boolean(d.supportsStoredProcedures()));
900: //boolean supportsStoredProcedures() throws SQLException;
901: rows[57].add("supportsSubqueriesInComparisons");
902: rows[57].add(new Boolean(d.supportsSubqueriesInComparisons()));
903: //boolean supportsSubqueriesInComparisons() throws SQLException;
904: rows[58].add("supportsSubqueriesInExists");
905: rows[58].add(new Boolean(d.supportsSubqueriesInExists()));
906: //boolean supportsSubqueriesInExists() throws SQLException;
907: rows[59].add("supportsSubqueriesInIns");
908: rows[59].add(new Boolean(d.supportsSubqueriesInIns()));
909: //boolean supportsSubqueriesInIns() throws SQLException;
910: rows[60].add("supportsSubqueriesInQuantifieds");
911: rows[60].add(new Boolean(d.supportsSubqueriesInQuantifieds()));
912: //boolean supportsSubqueriesInQuantifieds() throws SQLException;
913: rows[61].add("supportsCorrelatedSubqueries");
914: rows[61].add(new Boolean(d.supportsCorrelatedSubqueries()));
915: //boolean supportsCorrelatedSubqueries() throws SQLException;
916: rows[62].add("supportsUnion");
917: rows[62].add(new Boolean(d.supportsUnion()));
918: //boolean supportsUnion() throws SQLException;
919: rows[63].add("supportsUnionAll");
920: rows[63].add(new Boolean(d.supportsUnionAll()));
921: //boolean supportsUnionAll() throws SQLException;
922: rows[64].add("supportsOpenCursorsAcrossCommit");
923: rows[64].add(new Boolean(d.supportsOpenCursorsAcrossCommit()));
924: //boolean supportsOpenCursorsAcrossCommit() throws SQLException;
925: rows[65].add("supportsOpenCursorsAcrossRollback");
926: rows[65].add(new Boolean(d.supportsOpenCursorsAcrossRollback()));
927: //boolean supportsOpenCursorsAcrossRollback() throws SQLException;
928: rows[66].add("supportsOpenStatementsAcrossCommit");
929: rows[66].add(new Boolean(d.supportsOpenStatementsAcrossCommit()));
930: //boolean supportsOpenStatementsAcrossCommit() throws SQLException;
931: rows[67].add("supportsOpenStatementsAcrossRollback");
932: rows[67].add(new Boolean(d.supportsOpenStatementsAcrossRollback()));
933: //boolean supportsOpenStatementsAcrossRollback() throws SQLException;
934: rows[68].add("doesMaxRowSizeIncludeBlobs");
935: rows[68].add(new Boolean(d.doesMaxRowSizeIncludeBlobs()));
936: //boolean doesMaxRowSizeIncludeBlobs() throws SQLException;
937: rows[69].add("supportsTransactions");
938: rows[69].add(new Boolean(d.supportsTransactions()));
939: //boolean supportsTransactions() throws SQLException;
940: rows[70].add("supportsTransactionIsolationLevel");
941: rows[70].add(new Boolean(d.supportsTransactionIsolationLevel(1)));
942: //boolean supportsTransactionIsolationLevel(int level) throws SQLException;
943: rows[71].add("supportsDataDefinitionAndDataManipulationTransactions");
944: rows[71].add(new Boolean(d.supportsDataDefinitionAndDataManipulationTransactions()));
945: //boolean supportsDataDefinitionAndDataManipulationTransactions() throws SQLException;
946: rows[72].add("supportsDataManipulationTransactionsOnly");
947: rows[72].add(new Boolean(d.supportsDataManipulationTransactionsOnly()));
948: //boolean supportsDataManipulationTransactionsOnly() throws SQLException;
949: rows[73].add("dataDefinitionCausesTransactionCommit");
950: rows[73].add(new Boolean(d.dataDefinitionCausesTransactionCommit()));
951: //boolean dataDefinitionCausesTransactionCommit() throws SQLException;
952: rows[74].add("dataDefinitionIgnoredInTransactions");
953: rows[74].add(new Boolean(d.dataDefinitionIgnoredInTransactions()));
954: //boolean dataDefinitionIgnoredInTransactions() throws SQLException;
955: rows[75].add("getMaxBinaryLiteralLength");
956: rows[75].add(new Integer(d.getMaxBinaryLiteralLength()));
957: // int getMaxBinaryLiteralLength() throws SQLException;
958: rows[76].add("getMaxCharLiteralLength");
959: rows[76].add(new Integer(d.getMaxCharLiteralLength()));
960: //int getMaxCharLiteralLength() throws SQLException;
961: rows[77].add("getMaxColumnNameLength");
962: rows[77].add(new Integer(d.getMaxColumnNameLength()));
963: // int getMaxColumnNameLength() throws SQLException;
964: rows[78].add("getMaxColumnsInGroupBy");
965: rows[78].add(new Integer(d.getMaxColumnsInGroupBy()));
966: //int getMaxColumnsInGroupBy() throws SQLException;
967: rows[79].add("getMaxColumnsInIndex");
968: rows[79].add(new Integer(d.getMaxColumnsInIndex()));
969: //int getMaxColumnsInIndex() throws SQLException;
970: rows[80].add("getMaxColumnsInOrderBy");
971: rows[80].add(new Integer(d.getMaxColumnsInOrderBy()));
972: //int getMaxColumnsInOrderBy() throws SQLException;
973: rows[81].add("getMaxColumnsInSelect");
974: rows[81].add(new Integer(d.getMaxColumnsInSelect()));
975: //int getMaxColumnsInSelect() throws SQLException;
976: rows[82].add("getMaxColumnsInTable");
977: rows[82].add(new Integer(d.getMaxColumnsInTable()));
978: //int getMaxColumnsInTable() throws SQLException;
979: rows[83].add("getMaxConnections");
980: rows[83].add(new Integer(d.getMaxConnections()));
981: //int getMaxConnections() throws SQLException;
982: rows[84].add("getMaxCursorNameLength");
983: rows[84].add(new Integer(d.getMaxCursorNameLength()));
984: // int getMaxCursorNameLength() throws SQLException;
985: rows[85].add("getMaxIndexLength");
986: rows[85].add(new Integer(d.getMaxIndexLength()));
987: //int getMaxIndexLength() throws SQLException;
988: rows[86].add("getMaxSchemaNameLength");
989: rows[86].add(new Integer(d.getMaxSchemaNameLength()));
990: //int getMaxSchemaNameLength() throws SQLException;
991: rows[87].add("getMaxProcedureNameLength");
992: rows[87].add(new Integer(d.getMaxProcedureNameLength()));
993: //int getMaxProcedureNameLength() throws SQLException;
994: rows[88].add("getMaxCatalogNameLength");
995: rows[88].add(new Integer(d.getMaxCatalogNameLength()));
996: //int getMaxCatalogNameLength() throws SQLException;
997: rows[89].add("getMaxRowSize");
998: rows[89].add(new Integer(d.getMaxRowSize()));
999: //int getMaxRowSize() throws SQLException;
1000: rows[90].add("getMaxStatementLength");
1001: rows[90].add(new Integer(d.getMaxStatementLength()));
1002: //int getMaxStatementLength() throws SQLException;
1003: rows[91].add("getMaxStatements");
1004: rows[91].add(new Integer(d.getMaxStatements()));
1005: //int getMaxStatements() throws SQLException;
1006: rows[92].add("getMaxTableNameLength");
1007: rows[92].add(new Integer(d.getMaxTableNameLength()));
1008: //int getMaxTableNameLength() throws SQLException;
1009: rows[93].add("getMaxTablesInSelect");
1010: rows[93].add(new Integer(d.getMaxTablesInSelect()));
1011: //int getMaxTablesInSelect() throws SQLException;
1012: rows[94].add("getMaxUserNameLength");
1013: rows[94].add(new Integer(d.getMaxUserNameLength()));
1014: // int getMaxUserNameLength() throws SQLException;
1015: rows[95].add("getDefaultTransactionIsolation");
1016: rows[95].add(new Integer(d.getDefaultTransactionIsolation()));
1017: //int getDefaultTransactionIsolation() throws SQLException;
1018:
1019: rows[96].add("getDatabaseProductName");
1020: rows[96].add(d.getDatabaseProductName());
1021: // String getDatabaseProductName() throws SQLException;
1022: rows[97].add("getDatabaseProductVersion");
1023: rows[97].add(d.getDatabaseProductVersion());
1024: //String getDatabaseProductVersion() throws SQLException;
1025:
1026: rows[98].add("getURL");
1027: rows[98].add(d.getURL());
1028: //String getURL() throws SQLException;
1029: rows[99].add("getUserName");
1030: rows[99].add(d.getUserName());
1031: //String getUserName() throws SQLException;
1032: rows[100].add("getDriverName");
1033: rows[100].add(d.getDriverName());
1034: // String getDriverName() throws SQLException;
1035: rows[101].add("getIdentifierQuoteString");
1036: rows[101].add(d.getIdentifierQuoteString());
1037: //String getIdentifierQuoteString() throws SQLException;
1038:
1039: rows[102].add("getDriverVersion");
1040: rows[102].add(d.getDriverVersion());
1041: //String getDriverVersion() throws SQLException;
1042: rows[103].add("getDriverMajorVersion");
1043: rows[103].add(new Integer(d.getDriverMajorVersion()));
1044: //int getDriverMajorVersion();
1045: rows[104].add("getDriverMinorVersion");
1046: rows[104].add(new Integer(d.getDriverMinorVersion()));
1047: //int getDriverMinorVersion();
1048: rows[105].add("getSQLKeywords");
1049: rows[105].add(d.getSQLKeywords());
1050: //String getSQLKeywords() throws SQLException;
1051: rows[106].add("getNumericFunctions");
1052: rows[106].add(d.getNumericFunctions());
1053: //String getNumericFunctions() throws SQLException;
1054: rows[107].add("getStringFunctions");
1055: rows[107].add(d.getStringFunctions());
1056: // String getStringFunctions() throws SQLException;
1057: rows[108].add("getSystemFunctions");
1058: rows[108].add(d.getSystemFunctions());
1059: //String getSystemFunctions() throws SQLException;
1060: rows[109].add("getTimeDateFunctions");
1061: rows[109].add(d.getTimeDateFunctions());
1062: //String getTimeDateFunctions() throws SQLException;
1063: rows[110].add("getSearchStringEscape");
1064: rows[110].add(d.getSearchStringEscape());
1065: //String getSearchStringEscape() throws SQLException;
1066: rows[111].add("getExtraNameCharacters");
1067: rows[111].add(d.getExtraNameCharacters());
1068: //String getExtraNameCharacters() throws SQLException;
1069: rows[112].add("getSchemaTerm");
1070: rows[112].add(d.getSchemaTerm());
1071: //String getSchemaTerm() throws SQLException;
1072: rows[113].add("getProcedureTerm");
1073: rows[113].add(d.getProcedureTerm());
1074: //String getProcedureTerm() throws SQLException;
1075: rows[114].add("getCatalogTerm");
1076: rows[114].add(d.getCatalogTerm());
1077: // String getCatalogTerm() throws SQLException;
1078: rows[115].add("getCatalogSeparator");
1079: rows[115].add(d.getCatalogSeparator());
1080: //String getCatalogSeparator() throws SQLException;
1081:
1082: /*
1083: boolean supportsResultSetType(int type) throws SQLException;
1084:
1085: boolean supportsResultSetConcurrency(int type, int concurrency) throws SQLException;
1086:
1087: boolean ownUpdatesAreVisible(int type) throws SQLException;
1088:
1089: boolean ownDeletesAreVisible(int type) throws SQLException;
1090:
1091: boolean ownInsertsAreVisible(int type) throws SQLException;
1092:
1093: boolean othersUpdatesAreVisible(int type) throws SQLException;
1094:
1095: boolean othersDeletesAreVisible(int type) throws SQLException;
1096:
1097: boolean othersInsertsAreVisible(int type) throws SQLException;
1098: boolean updatesAreDetected(int type) throws SQLException;
1099: boolean deletesAreDetected(int type) throws SQLException;
1100:
1101: boolean insertsAreDetected(int type) throws SQLException;
1102: */
1103: // not in filemaker
1104: // rows[96].add("supportsBatchUpdates");
1105: // rows[96].add(new Boolean(d.supportsBatchUpdates()));
1106: //boolean supportsBatchUpdates() throws SQLException;
1107:
1108: /*
1109: ResultSet getProcedures(String catalog, String schemaPattern, String procedureNamePattern) throws SQLException;
1110:
1111: ResultSet getProcedureColumns(String catalog, String schemaPattern, String procedureNamePattern, String columnNamePattern) throws SQLException;
1112: ResultSet getTables(String catalog, String schemaPattern, String tableNamePattern, String types[]) throws SQLException;
1113: ResultSet getSchemas() throws SQLException;
1114: ResultSet getCatalogs() throws SQLException;
1115: ResultSet getTableTypes() throws SQLException;
1116: ResultSet getColumns(String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern) throws SQLException;
1117: ResultSet getPrimaryKeys(String catalog, String schema, String table) throws SQLException;
1118: ResultSet getImportedKeys(String catalog, String schema, String table) throws SQLException;
1119: ResultSet getExportedKeys(String catalog, String schema, String table) throws SQLException;
1120: ResultSet getCrossReference(String primaryCatalog, String primarySchema, String primaryTable, String foreignCatalog, String foreignSchema, String foreignTable) throws SQLException;
1121: ResultSet getTypeInfo() throws SQLException;
1122: ResultSet getIndexInfo(String catalog, String schema, String table, boolean unique, boolean approximate) throws SQLException;
1123:
1124: ResultSet getUDTs(String catalog, String schemaPattern, String typeNamePattern, int[] types) throws SQLException;
1125:
1126: Connection getConnection() throws SQLException;
1127:
1128: */
1129: for (int i = 0; i < rows.length; ++i)
1130: cols.add(rows[i]);
1131: data[0] = cols;
1132: data[1] = columnNames;
1133: return data;
1134: }
1135: public Vector getNextRow() throws Exception
1136: {
1137:
1138: if (result == null)
1139: return null;
1140: boolean check = false;
1141: ResultSet resultSet = result;
1142: ResultSetMetaData metaData = resultSet.getMetaData();
1143: int columnCount = metaData.getColumnCount();
1144: Vector tableData = new Vector();
1145: check = resultSet.next();
1146: // System.out.println("hallo check "+check);
1147: if (!check)
1148: return null;
1149: Vector tableRow = new Vector(), m_columnClasses = new Vector();
1150: for (int i = 1; i <= columnCount; i++)
1151: {
1152: // repeating fields and fields from related databases may contain
1153: // multliple data values; the data values are stored using
1154: // a Vector which is then added to the tableRow
1155: // if (metaData instanceof ResultSetMetaDataExt)
1156: if ((metaData instanceof ResultSetMetaDataExt) && (((ResultSetMetaDataExt) metaData).isRelated(i) || ((ResultSetMetaDataExt) metaData).isRepeating(i)))
1157: {
1158: //System.out.println("Related fields");
1159: // retrieve the repeating or related field contents as a
1160: // com.fmi.jdbc.Array via the ResultSet.getObject method
1161: com.fmi.jdbc.Array array = (com.fmi.jdbc.Array) resultSet.getObject(i);
1162: // create a Vector for storing all of the data values
1163: ArrayList columnData = new ArrayList();
1164: try
1165: {
1166:
1167: // call the Array.getStringArray method since the data will
1168: // only be displayed
1169: Object[] fieldData = (Object[]) array.getArray();
1170:
1171: if (fieldData != null)
1172: {
1173: // add each value to the Vector
1174: for (int j = 0; j < fieldData.length; j++)
1175: {
1176: if (fieldData[j] != null)
1177: columnData.add(fieldData[j]);
1178: }
1179: }
1180: } catch (Exception e)
1181: {
1182: //System.out.println(e);
1183: }
1184:
1185: if (columnData.isEmpty())
1186: tableRow.add(null);
1187: else
1188: tableRow.addElement(columnData);
1189: //System.out.println(columnData);
1190: //System.out.println("Related fields"+columnData.size()+" "+tableRow.size());
1191:
1192: // m_columnClasses.addElement(java.util.Vector.class);
1193: } else if (metaData.getColumnType(i) == Types.LONGVARBINARY)
1194: {
1195: // use the ResultSet.getObject method for retrieving images
1196: // from FileMaker Pro container fields; the ResultSet.getObject
1197: // method returns a java.awt.Image object for FileMaker Pro
1198: // container fields
1199:
1200: try
1201: {
1202: tableRow.addElement(resultSet.getObject(i));
1203: } catch (Exception e)
1204: {
1205: // TODO Auto-generated catch block
1206: // e.printStackTrace();
1207: tableRow.addElement(null);
1208: }
1209: // m_columnClasses.addElement(java.awt.Image.class);
1210: } else if (metaData.getColumnType(i) == Types.TIME)
1211: {
1212: // use the ResultSet.getObject method for retieving images
1213: // from FileMaker Pro container fields; the ResultSet.getObject
1214: // method returns a java.awt.Image object for FileMaker Pro
1215: // container fields
1216: try
1217: {
1218: tableRow.addElement(resultSet.getTime(i).toString());
1219: // m_columnClasses.addElement(java.sql.Time.class);
1220: } catch (Exception e)
1221: {
1222:
1223: String value = resultSet.getString(i);
1224: if (value != null)
1225: {
1226: //System.out.println("SQLTime new "+Time.valueOf("17:00:00").toString());
1227: int index = 0;
1228: for (int j = 0; j < value.length(); ++j)
1229: {
1230: if (!Character.isLetter(value.charAt(j)))
1231: index = j + 1;
1232: else
1233: break;
1234: }
1235:
1236: tableRow.addElement(value.substring(0, index));
1237: //m_columnClasses.addElement(java.sql.Time.class);
1238: } else
1239: tableRow.add(null);
1240: // m_columnClasses.addElement(String.class);
1241: } // to catch
1242:
1.10 rogo 1243: } else if (metaData.getColumnType(i) == Types.INTEGER)
1244: {
1245: // use the ResultSet.getObject method for retieving images
1246: // from FileMaker Pro container fields; the ResultSet.getObject
1247: // method returns a java.awt.Image object for FileMaker Pro
1248: // container fields
1249:
1250: tableRow.addElement(new Integer(resultSet.getInt(i)));
1251: // m_columnClasses.addElement(java.sql.Date.class);
1252: } else if (metaData.getColumnType(i) == Types.DATE)
1253: {
1.1 rogo 1254: // use the ResultSet.getObject method for retieving images
1255: // from FileMaker Pro container fields; the ResultSet.getObject
1256: // method returns a java.awt.Image object for FileMaker Pro
1257: // container fields
1258:
1259: tableRow.addElement(resultSet.getDate(i));
1260: // m_columnClasses.addElement(java.sql.Date.class);
1261: } else if (metaData.getColumnTypeName(i) == "NUMBER")
1262: {
1263: // use the ResultSet.getObject method for retieving images
1264: // from FileMaker Pro container fields; the ResultSet.getObject
1265: // method returns a java.awt.Image object for FileMaker Pro
1266: // container fields
1267: try
1268: {
1269: tableRow.addElement(new Integer(resultSet.getInt(i)));
1270: // m_columnClasses.addElement(Integer.class);
1271:
1272: } catch (Exception e)
1273: {
1274:
1275: StringBuffer number = new StringBuffer();
1276: String value = resultSet.getString(i);
1277: System.out.println(value);
1278: for (int c = 0; c < value.length(); ++c)
1279: {
1280: if (Character.isDigit(value.charAt(c)))
1281: {
1282: number.append(value.charAt(c));
1283: }
1284: }
1285: if (number.length() > 0)
1286: {
1287: tableRow.addElement(null);
1288: // m_columnClasses.addElement(Integer.class);
1289: } else
1290: tableRow.addElement(null);
1291: }
1292: } else
1293: {
1294: // all other field values are retrieved as strings and
1295: // added to the tableRow Vector
1296: // System.out.println("row "+resultSet.getString(i));
1297: try
1298: {
1299: byte[] b = null;
1300: if (metaData instanceof ResultSetMetaDataExt)
1301: b = resultSet.getBytes(i);
1302: String utf8 = null;
1303: utf8 = (b == null) ? null : new String(b);
1304: if (metaData instanceof ResultSetMetaDataExt)
1305: tableRow.addElement((b != null) ? new String(utf8.getBytes()) : null);
1306: else
1307: {
1308: // byte[] val = resultSet.getBytes(i);
1309: tableRow.add(resultSet.getString(i));
1310: //tableRow.addElement((val==null) ? null:new String(val,"UTF-8"));
1311: }
1312: } catch (Exception e)
1313: {
1314: System.out.println("Hey I Got an error" + e);
1315: e.printStackTrace();
1316: }
1317: // m_columnClasses.addElement(java.lang.String.class);
1318: }
1319: }
1320: // tableData.addElement(tableRow);
1321: if (check)
1322: return tableRow;
1323: else
1324: return null;
1325: }
1326: class ConnectionPool
1327: {
1328: String user = "", passwd = "", url = "";
1329: Connection con;
1330: public ConnectionPool(String url, String user, String passwd, Connection con)
1331: {
1332: this.con = con;
1333: this.user = user;
1334: this.passwd = passwd;
1335: this.url = url;
1336: }
1337:
1338: }
1339: public String getQC()
1340: {
1341: // if (connection == null)
1342: // return "";
1343:
1344: // check if connection null if null try to get one
1345: if (connection == null)
1346: try
1347: {
1348: getConnection();
1349: } catch (Exception e)
1350: {
1351: if (FM2SQL.debug)
1352: System.out.println("cannot get a connection");
1353: }
1354: if (connection == null)
1355: {
1356: if (url.toLowerCase().indexOf("fmpro") >= 0 || url.toLowerCase().indexOf("postgres") >= 0)
1357: quoteChar = "\"";
1358: else if (url.toLowerCase().indexOf("mysql") >= 0)
1359: quoteChar = "`";
1360: }
1361: if (quoteChar == null)
1362: quoteChar = "\""; // needed for postgres
1363: return quoteChar;
1364: }
1365: public int getRowCount(String query) throws SQLException
1366: {
1367: String table = query.substring(query.indexOf("from") + 4).trim();
1368: int index = table.indexOf(" ");
1369: table = table.substring(0, (index >= 0) ? index : table.length());
1370: System.out.println(table);
1371: Statement stm = null;
1372:
1373: if (metaData instanceof ResultSetMetaDataExt)
1374: return 1000;
1375: if (!connection.isClosed())
1376: stm = connection.createStatement();
1377: stm.setMaxRows(1);
1378: ResultSet resultSet = stm.executeQuery("select count(*) from " + table);
1379: resultSet.next();
1380: return resultSet.getInt(1);
1381: }
1.8 rogo 1382: public TreeSet getIDVector(String id,String table,String query,int numHits) throws Exception
1.5 rogo 1383: {
1384: TreeSet t= new TreeSet();
1385: getConnection();
1386: ResultSet result = this.result;
1.7 rogo 1387: String subQuery = query.substring(query.lastIndexOf(table)+table.length()+1);
1388: System.out.println("subQuery "+subQuery);
1.8 rogo 1389: makeQuery("select "+id+" from "+getQC()+table+getQC()+subQuery,numHits );
1.5 rogo 1390: while(true)
1391: {
1.6 rogo 1392: Vector vec = getNextRow();
1393: if (vec == null)
1394: break;
1395: t.add(vec.get(0));
1.5 rogo 1396: }
1397: this.result=result;
1.10 rogo 1398: metaData = (this.result==null) ?null:this.result.getMetaData();
1.6 rogo 1399: return t;
1.5 rogo 1400: }
1401:
1402: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>