--- FM2SQL/Attic/DBBean.java 2004/01/30 13:19:23 1.7 +++ FM2SQL/Attic/DBBean.java 2004/03/23 11:57:06 1.11 @@ -1,3 +1,17 @@ +/* + * DBBean.java -- Class that ecapsulates all database actions + * Filemake to SQL Converter + * Copyright (C) 2004 Robert Gordesch (rogo@mpiwg-berlin.mpg.de) + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. Please read license.txt for the full details. A copy of + * the GPL may be found at http://www.gnu.org/copyleft/lgpl.html You should + * have received a copy of the GNU General Public License along with this + * program; if not, write to the Free Software Foundation, Inc., 59 Temple + * Place, Suite 330, Boston, MA 02111-1307 USA Created on 15.09.2003 by + * rogo + */ import java.sql.*; @@ -67,9 +81,9 @@ public class DBBean { DriverManager.registerDriver(new com.fmi.jdbc.JdbcDriver()); DriverManager.registerDriver((Driver) Class.forName("org.postgresql.Driver").newInstance()); - DriverManager.registerDriver((Driver) Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance()); DriverManager.registerDriver((Driver) Class.forName("com.mysql.jdbc.Driver").newInstance()); - + DriverManager.registerDriver((Driver) Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance()); + // wait a maximum of 10 seconds when attempting to establish a connection DriverManager.setLoginTimeout(10); } catch (Exception e) @@ -1226,8 +1240,17 @@ public class DBBean // m_columnClasses.addElement(String.class); } // to catch - } else if (metaData.getColumnType(i) == Types.DATE) - { + } else if (metaData.getColumnType(i) == Types.INTEGER) + { + // use the ResultSet.getObject method for retieving images + // from FileMaker Pro container fields; the ResultSet.getObject + // method returns a java.awt.Image object for FileMaker Pro + // container fields + + tableRow.addElement(new Integer(resultSet.getInt(i))); + // m_columnClasses.addElement(java.sql.Date.class); + } else if (metaData.getColumnType(i) == Types.DATE) + { // use the ResultSet.getObject method for retieving images // from FileMaker Pro container fields; the ResultSet.getObject // method returns a java.awt.Image object for FileMaker Pro @@ -1356,14 +1379,14 @@ public class DBBean resultSet.next(); return resultSet.getInt(1); } - public TreeSet getIDVector(String id,String table,String query) throws Exception + public TreeSet getIDVector(String id,String table,String query,int numHits) throws Exception { TreeSet t= new TreeSet(); getConnection(); ResultSet result = this.result; String subQuery = query.substring(query.lastIndexOf(table)+table.length()+1); System.out.println("subQuery "+subQuery); - makeQuery("select "+id+" from "+getQC()+table+getQC()+subQuery,0 ); + makeQuery("select "+id+" from "+getQC()+table+getQC()+subQuery,numHits ); while(true) { Vector vec = getNextRow(); @@ -1372,7 +1395,7 @@ public class DBBean t.add(vec.get(0)); } this.result=result; - metaData = this.result.getMetaData(); + metaData = (this.result==null) ?null:this.result.getMetaData(); return t; }