- Timestamp:
- 2005-05-16T11:02:50+12:00 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/doctypes/DocumentList.java
r8861 r9874 13 13 14 14 import java.sql.SQLException; 15 import java.sql.Statement; 15 16 import java.sql.ResultSet; 16 17 … … 68 69 select.setWhere(where); 69 70 70 this.connection.execute(select.toString()); 71 72 ResultSet results = this.connection.getResultSet(); 73 if (results != null) { 74 select = new GS3SQLSelect("filegroups"); 75 select.addField("DocID"); 76 select.setDistinct(true); 77 78 where = new GS3SQLWhere(); 79 where.setCondition(GS3SQLWhere.OR_CONDITION); 80 81 GS3SQLWhereItem whereItem = null; 82 83 try { 84 results.first(); 71 try { 72 Statement statement = connection.createStatement(); 73 ResultSet results = statement.executeQuery(select.toString()); 74 75 select = new GS3SQLSelect("filegroups"); 76 select.addField("DocID"); 77 select.setDistinct(true); 78 79 where = new GS3SQLWhere(); 80 where.setCondition(GS3SQLWhere.OR_CONDITION); 81 82 GS3SQLWhereItem whereItem = null; 83 84 results.first(); 85 85 do { 86 86 int fileGroupRef = results.getInt("FileGroupRef"); … … 90 90 while (results.next()); 91 91 select.setWhere(where); 92 results.close(); 93 94 this.connection.execute(select.toString()); 95 96 results = this.connection.getResultSet(); 92 93 results = statement.executeQuery(select.toString()); 94 97 95 results.first(); 98 96 do { … … 100 98 reply.add(docId); 101 99 } while (results.next()); 102 } 103 catch (SQLException sqlEx) 104 { System.err.println(sqlEx); 105 } 106 } 100 statement.close(); 101 } 102 catch (SQLException sqlEx) { 103 System.err.println("DocumentList.getDocumentIdsWithFile(): "+sqlEx); 104 } 105 107 106 return reply; 108 107 } … … 173 172 } 174 173 175 private List findDocumentIdsUsingFileQuery(String query) 176 { this.connection.execute(query); 177 178 try { 179 180 ResultSet results = this.connection.getResultSet(); 181 if (results == null || 182 !results.first()) { 183 return null; 184 } 174 private List findDocumentIdsUsingFileQuery(String query) { 175 176 try { 177 178 Statement statement = connection.createStatement(); 179 ResultSet results = statement.executeQuery(query); 180 181 if (!results.first()) { 182 statement.close(); 183 return null; 184 } 185 185 186 186 // get a list of group ids first and turn it into a query on filegroups … … 207 207 // structures...recreating new filegroup queries as necessary 208 208 while (queryBuffer.length() > 0) { 209 connection.execute(queryBuffer.toString());210 211 results = this.connection.getResultSet();212 if (results == null || !results.first()) {213 return null;209 results = statement.executeQuery(queryBuffer.toString()); 210 211 if (!results.first()) { 212 statement.close(); 213 return null; 214 214 } 215 215 … … 256 256 257 257 // execute the division query 258 this.connection.execute(queryBuffer.toString()); 259 260 results = this.connection.getResultSet(); 261 if (results == null || 262 !results.first()) { 263 return null; 258 results = statement.executeQuery(queryBuffer.toString()); 259 260 if (!results.first()) { 261 statement.close(); 262 return null; 264 263 } 265 264 … … 268 267 reply.add(results.getString("DocID")); 269 268 } while (results.next()); 270 269 270 statement.close(); 271 271 return reply; 272 272 } 273 273 catch (SQLException ex) { 274 System.err.println( ex);274 System.err.println("DocumentList.findDocumentIdsUsingFileQuery()"+ ex); 275 275 } 276 276 return null; … … 454 454 select.addField("*"); 455 455 456 ResultSet documents;457 456 try { 458 connection.execute(select.toString());459 documents = connection.getResultSet();460 461 if (documents.first()) 462 { do 463 { DocumentInterface document = AbstractDocument.readSQL(connection, documents);464 list.addDocument(document); 465 }466 while (documents.next());467 } 468 } 469 catch (java.sql.SQLException ex) 470 { System.out.println(ex);471 457 Statement statement = connection.createStatement(); 458 ResultSet documents = statement.executeQuery(select.toString()); 459 if (documents.first()) { 460 do { 461 DocumentInterface document = AbstractDocument.readSQL(connection, documents); 462 list.addDocument(document); 463 } 464 while (documents.next()); 465 } 466 statement.close(); 467 } 468 catch (java.sql.SQLException ex) { 469 System.out.println("DocumentList.writeSQLDocuments(): "+ex); 470 return null; 472 471 } 473 472 … … 487 486 { 488 487 private boolean hasNext; 488 private Statement statement; 489 489 private ResultSet resultSet; 490 490 private GS3SQLConnection connection; … … 498 498 499 499 try { 500 connection.execute(select.toString());501 this.resultSet = connection.getResultSet();500 this.statement = connection.createStatement(); 501 this.resultSet = statement.executeQuery(select.toString()); 502 502 this.hasNext = this.resultSet.first(); 503 503 } catch (SQLException ex) { 504 System.err.println("DocumentListIterator(): "+ex); 504 505 this.hasNext = false; 505 506 } … … 520 521 521 522 if (!this.hasNext) { 522 this.resultSet.close(); // be a good citizen & close used result sets523 this.statement.close(); // be a good citizen & close used statement 523 524 } 524 525 } catch (SQLException ex) { 526 System.err.println("DocumentList.iterator.next(): "+ex); 525 527 this.hasNext = false; 526 528 }
Note:
See TracChangeset
for help on using the changeset viewer.