H
hplovet
Unregistered / Unconfirmed
GUEST, unregistred user!
下面的方法使用了数据连接池,但为什么回有timeout现象?
public int getBlackuserCount(String blackStr)
{
int ret = 0;
ResultSet rs = null;
Statement stmt = null;
String readcatalog = blackStr;//"select count(*) form PRODUCTS where 1=1 and " +
try
{
//与连接池取的连接
Connection conn = ProjectConfig.ProjectDBPool.getConnection("DBConn");
stmt = conn.createStatement();
rs = stmt.executeQuery(readcatalog);
if (rs.next())
{
ret = rs.getInt(1);
}
}
catch (SQLException ex)
{
log.error("使用数据连接池出错或执行SQL出错:" + ex.getMessage());
}
finally
{
try
{
rs.close();
ProjectConfig.ProjectDBPool.freeConnection("DBConn", conn);
}
catch (Exception e)
{
log.error("关闭数据库出错" + e.getMessage());
}
}
return ret;
}
public int getBlackuserCount(String blackStr)
{
int ret = 0;
ResultSet rs = null;
Statement stmt = null;
String readcatalog = blackStr;//"select count(*) form PRODUCTS where 1=1 and " +
try
{
//与连接池取的连接
Connection conn = ProjectConfig.ProjectDBPool.getConnection("DBConn");
stmt = conn.createStatement();
rs = stmt.executeQuery(readcatalog);
if (rs.next())
{
ret = rs.getInt(1);
}
}
catch (SQLException ex)
{
log.error("使用数据连接池出错或执行SQL出错:" + ex.getMessage());
}
finally
{
try
{
rs.close();
ProjectConfig.ProjectDBPool.freeConnection("DBConn", conn);
}
catch (Exception e)
{
log.error("关闭数据库出错" + e.getMessage());
}
}
return ret;
}