Also, if you revise the code above to the following lines:
Code:
ScrollableResults sr = emSybase.getSession()
.createQuery("from Audittrail2")
.setReadOnly( true )
.scroll( ScrollMode.SCROLL_INSENSITIVE );
sr.next();
sr.close();
It will hang your application.. (perhaps forever?)
When I paused the thread, you will see it is stuck on line 206:
Code:
200 public void closeQueryStatement(PreparedStatement ps, ResultSet rs) throws SQLException {
201 boolean psStillThere = statementsToClose.remove( ps );
202 try {
203 if ( rs != null ) {
204 if ( resultSetsToClose.remove( rs ) ) {
205 logCloseResults();
206 rs.close();
207 }
208 }
209 }
But using the pure JDBC like on the following lines I got no problems on closing the resultset unlike above code on line 206:
Code:
try
{
Class.forName( "com.sybase.jdbc3.jdbc.SybDriver" );
}
catch (ClassNotFoundException e)
{
e.printStackTrace();
}
ResultSet rs = null;
Connection con = null;
Statement st = null;
try
{
con = DriverManager.getConnection(
"jdbc:sybase:Tds:stage.brokerhub.net:4100/SERVER",
"sa",
"close2come");
st = con.createStatement( ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_READ_ONLY );
st.setCursorName( "myCursor" );
rs = st.executeQuery("select * from AUDITTRAIL");
rs.next();
rs.close();
}
catch( SQLException e)
{
e.printStackTrace();
}