`
xumingrencai
  • 浏览: 1190771 次
文章分类
社区版块
存档分类
最新评论

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){}
}
}

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics