Changeset 6865


Ignore:
Timestamp:
2004-02-24T11:01:01+13:00 (20 years ago)
Author:
kjdon
Message:

put a try-catch around creating and testing the connection to the db

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/util/SQLQuery.java

    r6516 r6865  
    1717
    1818    public boolean setDatabase(String db_name) {
    19     connection = GS3SQLConnectionFactory.createConnection(db_name);
    20 
    21     // test the connection
    22     String query = "select * from "+GSSQL.DOCUMENT_TABLE+GSSQL.END;
    23     if (!connection.execute(query)) {
    24         connection = null;
     19    try {
     20        connection = GS3SQLConnectionFactory.createConnection(db_name);
     21       
     22        // test the connection
     23        String query = "select * from "+GSSQL.DOCUMENT_TABLE+GSSQL.END;
     24        if (!connection.execute(query)) {
     25        connection = null;
     26        return false;
     27        }
     28        return true;
     29    } catch (Exception e) {
     30        System.err.println("SQLQuery.setDatabase Exception");
    2531        return false;
    2632    }
    27     return true;
    2833    }
    2934
Note: See TracChangeset for help on using the changeset viewer.