JBoss3.0.1, Informix 7.31, Prepared statement and Blob
fred_soulier Aug 19, 2002 4:59 AMHi,
Configuration
-------------
JDK 1.3.1_04 (Linux or W2K)
JBoss3.01
Informix 7.31
JDBC Driver (com.informix.jdbc.IfxDriver)
We are getting this "No ManagedConnections Available" msg after our application runs for a while.
I have traced the pbm down to a PreparedStatement which updates a Blob.
I did source trace the DAO and could see the Prepared Statement and the connection being closed... Yet on the Informix Server Admin I can see the connection is still there with the last SQL statement executed being the one from the DAO. Everytime this method is invoked we end up with one more connection opened and not close for no obvious reason.
The datasource has been configured using the informix-service.xml example in /docs/examples/jca and the managed connection pool is set to min=2 max=50
Note: we do not have this problem using Sun j2ee 1.3.1_02
Here is the method in our DAO:
void saveBasket(BasketContext basketContext)
throws DAOException
{
final String METHOD_NAME = "saveBasket";
PreparedStatement pstmt = null;
try
{
conn = getConnection();
String sql = "update tb_basket set BASKET_CONTEXT = ?, " +
"last_modified_by = '" + CLASS_NAME + "', " +
"last_modified_timestamp = CURRENT " +
"where basket_id = '" + basketContext.getBasketId().getId() + "'";
pstmt = conn.prepareStatement(sql);
ByteArrayOutputStream out = new ByteArrayOutputStream();
ObjectOutputStream objStream = new ObjectOutputStream(out);
objStream.writeObject(basketContext);
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
objStream.flush();
pstmt.setBinaryStream(1, in, in.available());
try
{
pstmt.executeUpdate();
objStream.close();
out.close();
}
catch (SQLException e)
{
String err = "Failed to update table; nested exception is: \n" +e.getLocalizedMessage();
throw new DAOException(err);
}
}
catch (Exception e)
{
String err = "Unexpected error!; nested exception is: \n" +e.getLocalizedMessage();
throw new DAOException(err);
}
finally
{
try
{
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
if (conn != null)
{
conn.close();
conn = null;
}
}
catch (SQLException e)
{
String err = " Cannot close prepared statement or connection!; nested exception is: \n" +e.getLocalizedMessage();
throw new DAOException(err);
}
}
}
Thanks for any help.
/Fred