[Biojava-dev] misplaced close() in BioSQLSequenceDB.java

bradford powell bradford.powell at gmail.com
Fri Jul 8 21:26:15 EDT 2005


I put off tracking this down for a while, but whenever I would load a
new database the first attempt to access it would result in the
loading of the ontology followed by an exception. A second run would
just continue. The problem is that lines 267 and 268 of
org.biojava.bio.seq.db.biosql.BioSQLSequenceDB are:

      conn.close()
      dbid = getDBHelper().getInsertID(conn, "biodatabase", "biodatabase_id");

The second line throws an exception because 'conn' has already been
closed. This progresses down to the catch block at line 274, where
because 'conn' has been closed but is not null, an attempt is made to
close conn again, leading to the BioException which halts the program.

So, lines 267 and 268 should be reversed in order. And it may be
useful to change the criterion in the catch block of 274 to 'if (conn
!= null && !conn.isClosed())'. The latter change is only important if
there are other SQLExceptions that may be thrown after the connection
has been closed.



More information about the biojava-dev mailing list