昨天看了下資料庫連線池,有很多開源的連線池,為了方便就使用了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解決辦法
相關文章
- org.hibernate.exception.JDBCConnectionException: Cannot open connection 解決辦法ExceptionJDBC
- FTP Connection refused error 解決辦法FTPError
- DUBBO Thread pool is EXHAUSTED!thread
- ImportError: cannot import name ‘imresize‘解決辦法ImportError
- zabbix_get :command not found 解決辦法
- 解決 TypeError: Type aliases cannot be used with isinstance(). 辦法Error
- Excel匯入資料異常Cannot get a text value from a numeric cell解決辦法Excel
- FileZilla:425 Can't open data connection for transfer of解決辦法
- mac無法充電解決辦法!看來get下吧!Mac
- virtualbox中Cannot register the hard disk錯誤解決辦法
- Android Studio 出現“Cannot resolve symbol” 解決辦法AndroidSymbol
- Workspace in use or cannot be created, choose a different one.--錯誤解決辦法
- Connection to https://dl-ssl.google.com refused的解決辦法HTTPGo
- ssh 安裝及登入提示:connection refused的解決辦法
- 解決org.hibernate.exception.GenericJDBCException: Cannot open connectionExceptionJDBC
- spring cvc-elt.1: Cannot find the declaration of element 'beans'解決辦法SpringBean
- Oracle Universal Connection Pool(UCP) for JDBC 詳解OracleJDBC
- YII GET方式引數重複/疊加的解決辦法
- 部署rac 提示ORA-15018: diskgroup cannot be created解決辦法
- mongodb錯誤解決辦法-bash: ./mongod: cannot execute binary file: Exec format errorMongoDBORMError
- ORA-01102: cannot mount database in EXCLUSIVE mode 的解決辦法Database
- .net sql connection pool leakSQL
- JDBC Connection Pool Example (轉)JDBC
- org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection 解決辦法SpringFrameworkJDBCOTGExceptionAI
- Laravel 安裝 sail時ubuntu軟體源很慢或者connection failed 解決辦法LaravelAIUbuntu
- github慢解決辦法Github
- Grub Rescue解決辦法
- /dev/null解決辦法devNull
- MSBuild Tools解決辦法UI
- oracle出異常:Io 異常: The Network Adapter could not establish the connection 解決辦法OracleAPT
- java.lang.String cannot be cast to com.alibaba.fastjson.JSONObject解決辦法JavaASTJSONObject
- 解決java connectionJava
- 檔案無法粉碎解決辦法
- OpenStack 的NAT解決辦法
- android ExceptionInInitializerError解決辦法AndroidExceptionError
- Could not find *.apk!解決辦法APK
- man出錯解決辦法
- ARP病毒解決辦法