To be totally safe on all drivers you should also close any result sets and
statements as well has connections, I use the following code as a template
for sql routines. This will make sure that everything is always closed.
Paul
Connection con = null;
Statement stmt = null;
ResultSet rs = null;
try {
con = ds.getConnection();
stmt = con.createStatement();
rs.executeQuery("sql here");
// etc
} finally {
if (rs != null) {
try {
rs.close();
} catch (SQLException sqle) {
}
}
if (stmt != null) {
try {
stmt.close();
} catch (SQLException sqle) {
}
}
if (con != null) {
try {
con.close();
} catch (SQLException sqle) {
}
}
}
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of danch (Dan
Christopherson)
Sent: 21 May 2001 16:29
To: [EMAIL PROTECTED]
Subject: Re: [JBoss-user] Database connection pool hangs...
You're probably not closing your connections. You should wrap all JDBC
code in a try ... finally where you close all resulsets, statements, and
connections (in that order)
-danch
Phan Anh Tran wrote:
> I found the problem. I ran out of connections with blocking enabled on
the
> pool.
>
> Anh
>
>>
>>This code is running in the context of a stateless session bean:
>>
>> Context initCtx = new InitialContext();
>> DataSource ds = (DataSource)initCtx.lookup("java:/" +
>>
> aDataSourceName);
>
>> Connection conn = ds.getConnection();
>>
>>The code hangs some where in the ds.getConnection() after 5-6 iterations
>>(calls to the bean's one and only method). Is this a jboss or a mm driver
>>problem?
>>
>>Thanks,
>>Anh
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user