昨天看了下数据库连接池,有很多开源的连接池,为了方便就使用了tomcat中带的连接池,
开始找了几篇文章,都没有弄成功,tomcat图形管理界面创建连接池的也不好用,
后来在网上找了一篇tomcat5.5的配置文章,总算是解决了,
按照下面的例子试了下,刷新几次后就出现了
Cannot get a connection, pool exhausted
后来搜了一下,是连接池被耗尽,
没有关闭con,
解决办法有3个:
1重启tomcat服务器
2吧maxactive值调大
3在finally中关闭conn
Context initCtx=new InitialContext();
DataSource ds = (DataSource)initCtx.lookup("java:comp/env/jdbc/mysql");
c.getConnection();
out.println("从数据库查询数据:<br>");
Statement stmt=conn.createStatement();
ResultSet rs =stmt.executeQuery("select * from userinfo");
while(rs.next())
{
out.println(rs.getString(1));
out.println(rs.getString(2));
}
rs.close();
stmt.close();
}
catch(Exception e)
{
e.printStackTrace();
}
finally
{
if(conn!=null)
conn.close();
}
Cannot get a connection, pool exhausted解决办法
转载本文章为转载内容,我们尊重原作者对文章享有的著作权。如有内容错误或侵权问题,欢迎原作者联系我们进行内容更正或删除文章。
下一篇:oracle按照时间过滤
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
gmail connection fail 解决办法
*.google.com*.gstatic.com*.googleapis.com
gmail connection fai -
cannot find main module 解决办法
置go.mod文件
github golang 环境变量 -
android library projects cannot be launched解决办法
properties 在android选项中将 is library中将前面的勾去了
android library proj android