Ignore:
Timestamp:
2005-05-12T14:52:45+12:00 (19 years ago)
Author:
kjdon
Message:

OK, changed my mind about making SQLConnection kill off the previous statement.
To make it more transparent what is happening, you now have to create a Statement (connection.createStatement()), then use the Statement to execute the query. This means that the thing doing the query owns the Statement, and can kill it off when finished with it, and nothing else can kill it off unexpectedly. The previous way this was all implemented meant that there was a large memory leak, and some functionality actually relied on this. A newer version of the mysql connector/J has fixed the bug where the statement wasn't closed on garbage collection, but it still seems better to close it explicitly.
Hopefully I have got it all back to working as well as it was bfore, and haven't introduced any bugs :-)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/gs3build/notifier/NotifierManager.java

    r9848 r9858  
    2727    String lastBuild = dateToSqlString(collManager.getBuildDate());
    2828    System.out.println("last build was " + lastBuild);
    29     Statement statement = collManager.getDatabase().createStatement();
    3029        try {
     30        Statement statement = collManager.getDatabase().createStatement();
    3131            // detect all new documents. A document is new if and only if
    3232            // AccessionDate >= CollectionLastRebuiltDate
     
    130130    private String getDocumentTitle(String documentID, GS3SQLConnection database) {
    131131        System.out.println("getting title for document " + documentID + " from database");
    132         Statement statement = database.createStatement();
    133132
    134         ResultSet results;
    135133        try {
     134        Statement statement = database.createStatement();
    136135            String sqlString = "SELECT mdvalues.value " +
    137136        "FROM structure s JOIN divisions d ON (s.structureref = d.parentref) " +
     
    144143        "                                 AND d.parenttype = 'Structure' " +
    145144        "                                 AND m.docID = s.docid;";
    146             results = statement.executeQuery(sqlString);
    147             if (results.next()) {
     145            ResultSet results = statement.executeQuery(sqlString);
     146            if (results.first()) {
    148147                String title = results.getString("value");
    149148                System.out.println("title is " + title);
Note: See TracChangeset for help on using the changeset viewer.