[jboss-user] [Beginner's Corner] - Why am I still seeing the HouseKeepingMessage ?
Mads Moelgaard Andersen
do-not-reply at jboss.com
Fri Aug 20 06:26:40 EDT 2010
Mads Moelgaard Andersen [http://community.jboss.org/people/mda_dk] replied to the discussion
"Why am I still seeing the HouseKeepingMessage ?"
To view the discussion, visit: http://community.jboss.org/message/558298#558298
--------------------------------------------------------------
Hi
I've figured it out. After googling and googling and googling on the subject. I finally found a discussion on some forum that pointed me in the right direction. It lead me to organize my code like the following example
The method returns sql based on the sql passed to the database and data in the DB.
private String getGeneratedSql(String sql) throws Exception
{
logger.debug("Enter getGeneratedSql method.");
String result = null;
Connection conn = ds.getConnection();
try
{
Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
try
{
stmt.setFetchSize(this.mFetchSize);
ResultSet rs = stmt.executeQuery(sql);
try
{
if (rs.first()) result = rs.getString(1);
else throw new Exception("Could not retrive generated sql.");
}
finally
{
rs.close();
}
}
finally
{
stmt.close();
}
}
finally
{
conn.close();
logger.debug("Exit getGeneratedSql method.");
}
return result;
}
What seems essential to avoid the "HouseKeeping" warning and what I cannot explain is that open/close has to happen within the same scope, i.e same method or compound statement.
Anyway, thanks to the discussion that pushed me in the right direction.
Best regards
Mads M Andersen
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/558298#558298]
Start a new discussion in Beginner's Corner at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2075]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20100820/be8ca4ea/attachment.html
More information about the jboss-user
mailing list