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/classifier/AZListClassifier.java

    r8742 r9874  
    99import java.sql.ResultSet;
    1010import java.sql.SQLException;
     11import java.sql.Statement;
    1112
    1213import org.xml.sax.XMLReader;
     
    189190    select.setWhere(where);
    190191
    191     connection.execute(select.toString());
    192192
    193193    try {
    194       ResultSet results = connection.getResultSet();
    195       if (results != null && results.first()) {
     194      Statement statement = connection.createStatement();
     195      ResultSet results = statement.executeQuery(select.toString());
     196      if (results.first()) {
    196197    GS3SQLUpdate update = new GS3SQLUpdate("classifiers");
    197198    update.setWhere(where);
     
    206207
    207208    action = insert;
     209    classifyRef = -1;
    208210      }
    209211      action.addValue("ClassifyID", label);
     
    213215      action.addValue("NumLeafDocs", Integer.toString(noOfLeafDocs), GS3SQLField.INTEGER_TYPE);
    214216
    215       connection.execute(action.toString());
    216       classifyRef = -1;
    217     }
    218     catch (SQLException sqlEx) {
    219       System.err.println(sqlEx);
    220       return -1;
    221     }
    222 
    223     // get the ClassifyRef if we don't already have it (have done a
    224     // insert action above)...
    225     if (classifyRef == -1) {
    226       connection.execute(select.toString());
    227      
    228       try {
    229     ResultSet results = connection.getResultSet();
    230     if (results == null || !results.first()) {
     217      // do the update/insert
     218      statement.execute(action.toString());
     219
     220
     221      // get the ClassifyRef if we don't already have it (have done a
     222      // insert action above)...
     223      if (classifyRef == -1) {
     224    results = statement.executeQuery(select.toString());
     225    if (!results.first()) {
    231226      return -1;
    232227    }
     
    234229    classifyRef = results.getInt("ClassifyRef");
    235230      }
    236       catch (SQLException sqlEx) {
    237     System.err.println(sqlEx);
     231     
     232      statement.close();
     233    }  catch (SQLException sqlEx) {
     234    System.err.println("AZListClassifier.writeSQLClassifyNode(): "+sqlEx);
    238235    return -1;
    239       }
    240     }
     236    }
     237 
    241238
    242239    return classifyRef;
     
    274271    }
    275272
     273    try {
     274    Statement statement = connection.createStatement();
     275   
    276276    List children;
    277277   
     
    292292        Iterator iterator = childDocs.iterator();
    293293    int childOrder = 1;
     294    //St
    294295    while (iterator.hasNext()) {
    295296      AZDocumentItem documentItem = (AZDocumentItem) iterator.next();
     
    301302      insert.addValue("DocOrder", Integer.toString(childOrder), GS3SQLField.INTEGER_TYPE);   
    302303
    303       connection.execute(insert.toString());
     304      statement.execute(insert.toString());
    304305
    305306      childOrder ++;
     
    310311    }
    311312
     313   
    312314    /*
    313315    else {
     
    318320      delete.setWhere(where);
    319321
    320       connection.execute(delete.toString());
     322      statement.execute(delete.toString());
    321323    }
    322324
     
    331333    }
    332334    */
     335    statement.close();
     336    } catch (SQLException e) {
     337    System.err.println("AZListClassifier.writeSQL(): "+e);
     338    return false;
     339    }
    333340
    334341    return true;
Note: See TracChangeset for help on using the changeset viewer.