--- FM2SQL/Attic/DBBean.java 2003/12/05 11:46:39 1.1.1.1 +++ FM2SQL/Attic/DBBean.java 2004/01/30 13:19:23 1.7 @@ -1,5 +1,5 @@ -import java.io.ByteArrayOutputStream; -import java.io.PrintStream; + + import java.sql.*; import java.util.*; import com.fmi.jdbc.*; @@ -53,6 +53,7 @@ public class DBBean String url = ""; DatabaseMetaData dbMetaData; Vector columnNames; + Vector ids = new Vector(); String user = (System.getProperty("user.name") == null) ? "" : System.getProperty("user.name"); //"postgres"; String passwd = ""; //"3333";//"rogo"; public int maxHits = 10; @@ -194,6 +195,18 @@ public class DBBean quoteChar = "\""; // needed for postgres } + public void setIDVector(Vector ids) + { + this.ids = ids; + } + + /** + * returns a Vector containing the ID Row Name + **/ + public Vector getIDVector() + { + return ids; + } /** * returns a Vector containing the Tablenames or an error message in the Vector */ @@ -633,13 +646,21 @@ public class DBBean { result = null; Statement stm = null; + // System.out.println("Query " + query); if (!connection.isClosed()) stm = connection.createStatement(); stm.setMaxRows(numberOfHits); - result = stm.executeQuery(query); - // System.out.println(result+" "+stm.getMoreResults()); + long time = System.currentTimeMillis(); + stm.execute(query); + long time2 = System.currentTimeMillis(); + + System.out.println("time to execute "+(time2-time)); + // stm.setMaxRows(numberOfHits); + + result = stm.getResultSet(); + // System.out.println(result+" "+stm.getUpdateCount()); metaData = result.getMetaData(); return result; } @@ -1335,5 +1356,24 @@ public class DBBean resultSet.next(); return resultSet.getInt(1); } - -} + public TreeSet getIDVector(String id,String table,String query) 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 ); + while(true) + { + Vector vec = getNextRow(); + if (vec == null) + break; + t.add(vec.get(0)); + } + this.result=result; + metaData = this.result.getMetaData(); + return t; + } + +} \ No newline at end of file