Ignore:
Timestamp:
2005-05-16T11:02:50+12:00 (19 years ago)
Author:
kjdon
Message:

merged from branch ant-install-branch: merge 1

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/doctypes/DocumentList.java

    r8861 r9874  
    1313
    1414import java.sql.SQLException;
     15import java.sql.Statement;
    1516import java.sql.ResultSet;
    1617
     
    6869    select.setWhere(where);
    6970
    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();
    8585    do {
    8686      int fileGroupRef = results.getInt("FileGroupRef");
     
    9090    while (results.next());
    9191    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   
    9795    results.first();
    9896    do {
     
    10098      reply.add(docId);
    10199    } 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   
    107106    return reply;
    108107  }
     
    173172  }
    174173
    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    }
    185185     
    186186      // get a list of group ids first and turn it into a query on filegroups
     
    207207      // structures...recreating new filegroup queries as necessary
    208208      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;
    214214    }
    215215   
     
    256256     
    257257      // 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;
    264263      }
    265264
     
    268267    reply.add(results.getString("DocID"));
    269268      } while (results.next());
    270 
     269     
     270      statement.close();
    271271      return reply;
    272272    }
    273273    catch (SQLException ex) {
    274       System.err.println(ex);
     274      System.err.println("DocumentList.findDocumentIdsUsingFileQuery()"+ ex);
    275275    }
    276276    return null;
     
    454454    select.addField("*");
    455455   
    456     ResultSet documents;
    457456    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       return null;
     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;
    472471    }
    473472
     
    487486{
    488487  private boolean hasNext;
     488  private Statement statement;
    489489  private ResultSet resultSet;
    490490  private GS3SQLConnection connection;
     
    498498
    499499    try {
    500       connection.execute(select.toString());
    501       this.resultSet = connection.getResultSet();
     500    this.statement = connection.createStatement();
     501      this.resultSet = statement.executeQuery(select.toString());
    502502      this.hasNext = this.resultSet.first();
    503503    } catch (SQLException ex) {
     504      System.err.println("DocumentListIterator(): "+ex);
    504505      this.hasNext = false;
    505506    }
     
    520521
    521522      if (!this.hasNext) {
    522     this.resultSet.close(); // be a good citizen & close used result sets
     523      this.statement.close(); // be a good citizen & close used statement
    523524      }
    524525    } catch (SQLException ex) {
     526    System.err.println("DocumentList.iterator.next(): "+ex);
    525527      this.hasNext = false;
    526528    }
Note: See TracChangeset for help on using the changeset viewer.