|
From: Kopylenko, D. <dko...@ac...> - 2003-08-13 16:58:03
|
Would closing connection automatically take care of closing Statement and
ResultSet? I guess it all depends on the JDBC driver.
Dmitriy.
-----Original Message-----
From: Justinus Menzel [mailto:jus...@lb...]
Sent: Wednesday, August 13, 2003 12:09 PM
To: springframework-developer
Subject: [Springframework-developer]
JdbcTemplate.doWithResultSetFromStaticQuery cleanups
Hi,
first let me tell you that Spring is great, you guys rock!
Now to the question: if you look into
JdbcTemplate.doWithResultSetFromStaticQuery():
...
try {
con = DataSourceUtils.getConnection(this.dataSource);
s = con.createStatement();
rs = s.executeQuery(sql);
if (logger.isInfoEnabled())
logger.info("Executing static SQL query '" + sql + "'
using a java.sql.Statement");
rse.extractData(rs);
SQLWarning warning = s.getWarnings();
rs.close();
s.close();
throwExceptionOnWarningIfNotIgnoringWarnings(warning);
}
catch (SQLException ex) {
throw
getExceptionTranslater().translate("JdbcTemplate.query(sql)", sql, ex);
}
finally {
DataSourceUtils.closeConnectionIfNecessary(con,
this.dataSource);
}
...
it seems like rs.close() and s.close() will be executed only if there
was no exception thrown from
rse.extractData(). s.close will only be executed if rs =
s.executeQuery(sql); did OK.
So my question is: why don't both close() go into the finally block? The
reason why I'm asking this is that we had a few problems with
running out of cursors
in our application server and we also had a few
examples of queries not working correctly with certain input parameters.
any comments are much appreciated
thanks
Justinus
-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including Data
Reports, E-commerce, Portals, and Forums are available now. Download today
and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
_______________________________________________
Springframework-developer mailing list
Spr...@li...
https://lists.sourceforge.net/lists/listinfo/springframework-developer
|
|
From: Kopylenko, D. <dko...@ac...> - 2003-08-13 17:37:40
|
Well, Justinus, you are right. -----Original Message----- From: Justinus Menzel [mailto:jus...@lb...] Sent: Wednesday, August 13, 2003 1:13 PM To: spr...@li... Subject: Re: [Springframework-developer] JdbcTemplate.doWithResultSetFromStaticQuery cleanups Kopylenko, Dmitry wrote: >Would closing connection automatically take care of closing Statement >and ResultSet? I guess it all depends on the JDBC driver. > > well the thing is if it's a pooled connection, closing it doesn't really do anything except to return it to the pool. At least according to my naive understanding of things. But I might be wrong. Cheers Justinus ------------------------------------------------------- This SF.Net email sponsored by: Free pre-built ASP.NET sites including Data Reports, E-commerce, Portals, and Forums are available now. Download today and enter to win an XBOX or Visual Studio .NET. http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01 _______________________________________________ Springframework-developer mailing list Spr...@li... https://lists.sourceforge.net/lists/listinfo/springframework-developer |
|
From: Justinus M. <jus...@lb...> - 2003-08-13 17:30:05
|
Kopylenko, Dmitry wrote: >Would closing connection automatically take care of closing Statement and >ResultSet? I guess it all depends on the JDBC driver. > > well the thing is if it's a pooled connection, closing it doesn't really do anything except to return it to the pool. At least according to my naive understanding of things. But I might be wrong. Cheers Justinus |
|
From: <tri...@tr...> - 2003-08-13 18:39:23
|
According to JDBC 3.0 a pooled connection should close any statements when the close method is called, and so should a non-pooled connection. A statement should close any resultsets when it is closed. I don't think JDBC 2.0 was that explicit, and there might be a few JDBC drivers that are not well behaved. I'll take a look at adding close statements for all resultsets and statements in addition to the connections. This should not harm current functionality. Thomas > > > Kopylenko, Dmitry wrote: > > >Would closing connection automatically take care of closing Statement and > >ResultSet? I guess it all depends on the JDBC driver. > > > > > well the thing is if it's a pooled connection, closing it doesn't really > do anything except > to return it to the pool. At least according to my naive understanding > of things. > But I might be wrong. > > Cheers > > Justinus > > > > ------------------------------------------------------- > This SF.Net email sponsored by: Free pre-built ASP.NET sites including > Data Reports, E-commerce, Portals, and Forums are available now. > Download today and enter to win an XBOX or Visual Studio .NET. > http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01 > _______________________________________________ > Springframework-developer mailing list > Spr...@li... > https://lists.sourceforge.net/lists/listinfo/springframework-developer > |