As a workaround, would it be enough to call db.close()
in finally block upon exception?
like this:
try{
db.begin();
db.load(...);
db.remove(...);
db.commit();
finally {
if(db != null) {
db.close();
}
}
--- Martin Renner <[EMAIL PROTECTED]> wrote:
> Hi.
>
> Bug #870 describes that Statements and ResultSets
> are not always closed in
> SQLEngine.load().
>
> The same applies to SQLEngine.delete(). If any of
> the three
> PersistenceExceptions is thrown, the statement will
> never get closed.
>
> As a general rule I would suggest, that all
> resources HAVE to be put into a "try
> - finally" block. Otherwise, a Bug like #870 will
> occur again and again. To make
> the code more readable, I would add a small helper
> method to close statements
> and connections:
>
> ----+----+----+----+----+----
> public void methodLikeSQLEngineDelete(Object conn) {
> PreparedStatement stmt = null;
> try {
> stmt = ...;
> }
> finally {
> closeStatement(stmt);
> }
> }
>
> protected void closeStatement(Statement statement) {
> if (statement != null) {
> try {
> statement.close();
> }
> catch (Exception e) {}
> statement = null;
> }
> }
>
> protected void closeConnection(Connection
> connection) {
> if (connection != null) {
> try {
> connection.close();
> }
> catch (Exception e) {}
> connection = null;
> }
> }
> ----+----+----+----+----+----
>
>
> Martin
>
>
-----------------------------------------------------------
>
> If you wish to unsubscribe from this mailing, send
> mail to
> [EMAIL PROTECTED] with a subject of:
> unsubscribe castor-dev
>
__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev