connection 关闭方法

Connection conn = null;
ResultSet rs = null;
preparedStatement pss = null;
try
{
conn = dataSource.getConnection(USERID,pASSWORD);
pss = conn.prepareStatement("SELECT SAVESERIALZEDDATA FROM SESSION.pINGSESSION3DATA WHERE SESSIONKEY = ?");
pss.setString(1,sessionKey);
rs = pss.executeQuery();
pss.close();
conn.close();
}
catch (Throwable t)
{
// Insert Appropriate Error Handling Here
}
finally
{
// The finally clause is always executed - even in error
// conditions preparedStatements and Connections will always be closed
try
{
if (pss != null)
pss.close();
}
catch(Exception e) {}
try
{
if (conn != null)
conn.close();
}
catch (Exception e){}
}
}

你可能感兴趣的:(Connection)