Annotation of FM2SQL/DBBean.java, revision 1.24

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

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