Annotation of FM2SQL/src/DBBean.java, revision 1.5

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

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>