动态的创建连接,但是暂时只有一个连接为什么会报错说超过最大数量。
下面是我写的方法
public static DaoUp getNewConnect(String dbNo) {
DaoUp daoUp = null;
if (daoUpMap.get(dbNo) != null) {
return daoUpMap.get(dbNo);
}else {
try {
SysDbUrlDao sysDbUrlDao = Mvcs.getIoc().get(SysDbUrlDao.class, "sysDbUrlDao");
if (sysDbUrlDao != null) {
SysDbUrl sysDbUrl = sysDbUrlDao.fetch(dbNo);
DruidDataSource ds = new DruidDataSource();
ds.setDriverClassName(sysDbUrl.getDriver());
ds.setUrl(sysDbUrl.getUrlStr());
ds.setUsername(sysDbUrl.getUserName());
ds.setPassword(sysDbUrl.getPassword());
ds.setMaxWait(4000);
//ds.setRemoveAbandoned(true);
ds.setMaxActive(2);
//ds.setRemoveAbandonedTimeout(8);
ds.getConnection();
daoUp = new DaoUp(dbNo){
};
daoUp.setDataSource(ds);
daoUpMap.put(dbNo, daoUp);
return daoUp;
}else {
return null;
}
} catch (Exception e) {
e.printStackTrace();
}
return daoUp;
}
报错信息
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:122)08:58:48 [DEBUG] org.nutz.dao.impl.sql.run.NutDaoExecutor - SELECT
* FROM MODEL WHERE id=?
| 1 |
|----------------------------------|
| 0bce9561924b46bf96bb52eff4e08dab |
For example:> "SELECT * FROM MODEL WHERE id='0bce9561924b46bf96bb52eff4e08dab
'"
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(Authentica
torBase.java:505)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:170)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:103)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:
956)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
a:423)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp
11Processor.java:1079)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(
AbstractProtocol.java:625)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpo
int.java:2522)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoin
t.java:2511)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.
java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
.java:615)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskTh
read.java:61)
at java.lang.Thread.run(Thread.java:745)
Caused by: com.alibaba.druid.pool.GetConnectionTimeoutException: wait millis 400
0, active 8, maxActive 8
at com.alibaba.druid.pool.DruidDataSource.getConnectionInternal(DruidDat
aSource.java:1139)
at com.alibaba.druid.pool.DruidDataSource.getConnectionDirect(DruidDataS
ource.java:960)
at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.
java:940)
at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.
java:930)
at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.
java:102)
at org.nutz.dao.impl.sql.run.NutDaoRunner.run(NutDaoRunner.java:59)
... 51 more
org.nutz.dao.DaoException: com.alibaba.druid.pool.GetConnectionTimeoutException:
wait millis 4000, active 8, maxActive 8
at org.nutz.dao.impl.sql.run.NutDaoRunner.run(NutDaoRunner.java:78)
at org.nutz.dao.impl.DaoSupport._exec(DaoSupport.java:219)
at org.nutz.dao.impl.DaoSupport.execute(DaoSupport.java:197)
at org.nutz.dao.impl.NutDao.execute(NutDao.java:967)
at com.efraiser.ews.action.AppModelAction.getModelData(AppModelAction.ja
va:242)
at com.efraiser.ews.action.AppModelAction.getAppModelData(AppModelAction
.java:158)
at sun.reflect.GeneratedMethodAccessor33.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.nutz.mvc.impl.processor.MethodInvokeProcessor.process(MethodInvok
eProcessor.java:25)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcesso
r.java:44)
at org.nutz.mvc.impl.processor.AdaptorProcessor.process(AdaptorProcessor
.java:33)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcesso
r.java:44)
at org.nutz.mvc.impl.processor.ActionFiltersProcessor.process(ActionFilt
ersProcessor.java:40)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcesso
r.java:44)
at org.nutz.mvc.impl.processor.ModuleProcessor.process(ModuleProcessor.j
ava:113)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcesso
r.java:44)
at org.nutz.mvc.impl.processor.EncodingProcessor.process(EncodingProcess
or.java:27)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcesso
r.java:44)
at org.nutz.mvc.impl.processor.UpdateRequestAttributesProcessor.process(
UpdateRequestAttributesProcessor.java:15)
at org.nutz.mvc.impl.NutActionChain.doChain(NutActionChain.java:40)
at org.nutz.mvc.impl.ActionInvoker.invoke(ActionInvoker.java:67)
at org.nutz.mvc.ActionHandler.handle(ActionHandler.java:31)
at org.nutz.mvc.NutServlet.service(NutServlet.java:66)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52
)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:208)
at com.efraiser.filter.TokensFilter.doFilter(TokensFilter.java:64)
08:58:48 [DEBUG] org.nutz.mvc.impl.UrlMappingImpl - Found mapping for [POST] pat
h=/appModel/getAppModelData : AppModelAction.getAppModelData(...)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:241)
08:58:48 [DEBUG] org.nutz.ioc.impl.NutIoc - Get 'appModelAction'<class com.efrai
ser.ews.action.AppModelAction>
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:208)
at com.efraiser.filter.CorsFilter.doFilter(CorsFilter.java:33)
08:58:48 [DEBUG] org.nutz.dao.impl.sql.run.NutDaoExecutor - SELECT * FROM MODEL
WHERE id=?
| 1 |
|----------------------------------|
| f0885644f05440c797339de1b51aa727 |
For example:> "SELECT * FROM MODEL WHERE id='f0885644f05440c797339de1b51aa727
'"
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(Authentica
torBase.java:505)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:170)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:103)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:
956)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
a:423)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp
11Processor.java:1079)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(
AbstractProtocol.java:625)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpo
int.java:2522)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoin
t.java:2511)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.
java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
.java:615)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskTh
read.java:61)
at java.lang.Thread.run(Thread.java:745)
Caused by: com.alibaba.druid.pool.GetConnectionTimeoutException: wait millis 400
0, active 8, maxActive 8
at com.alibaba.druid.pool.DruidDataSource.getConnectionInternal(DruidDat
aSource.java:1139)
at com.alibaba.druid.pool.DruidDataSource.getConnectionDirect(DruidDataS
ource.java:960)
at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.
java:940)
at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.
java:930)
at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.
java:102)
at org.nutz.dao.impl.sql.run.NutDaoRunner.run(NutDaoRunner.java:59)
... 51 more
org.nutz.dao.DaoException: com.alibaba.druid.pool.GetConnectionTimeoutException:
wait millis 4000, active 8, maxActive 8
at org.nutz.dao.impl.sql.run.NutDaoRunner.run(NutDaoRunner.java:78)
at org.nutz.dao.impl.DaoSupport._exec(DaoSupport.java:219)
at org.nutz.dao.impl.DaoSupport.execute(DaoSupport.java:197)
at org.nutz.dao.impl.NutDao.execute(NutDao.java:967)
at com.efraiser.ews.action.AppModelAction.getModelData(AppModelAction.ja
va:242)
at com.efraiser.ews.action.AppModelAction.getAppModelData(AppModelAction
.java:158)
at sun.reflect.GeneratedMethodAccessor33.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.nutz.mvc.impl.processor.MethodInvokeProcessor.process(MethodInvok
eProcessor.java:25)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcesso
r.java:44)
at org.nutz.mvc.impl.processor.AdaptorProcessor.process(AdaptorProcessor
.java:33)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcesso
r.java:44)
at org.nutz.mvc.impl.processor.ActionFiltersProcessor.process(ActionFilt
ersProcessor.java:40)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcesso
r.java:44)
at org.nutz.mvc.impl.processor.ModuleProcessor.process(ModuleProcessor.j
ava:113)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcesso
r.java:44)
at org.nutz.mvc.impl.processor.EncodingProcessor.process(EncodingProcess
or.java:27)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcesso
r.java:44)
at org.nutz.mvc.impl.processor.UpdateRequestAttributesProcessor.process(
UpdateRequestAttributesProcessor.java:15)
at org.nutz.mvc.impl.NutActionChain.doChain(NutActionChain.java:40)
at org.nutz.mvc.impl.ActionInvoker.invoke(ActionInvoker.java:67)
at org.nutz.mvc.ActionHandler.handle(ActionHandler.java:31)
at org.nutz.mvc.NutServlet.service(NutServlet.java:66)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52
)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:208)
at com.efraiser.filter.TokensFilter.doFilter(TokensFilter.java:64)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:208)
at com.efraiser.filter.CorsFilter.doFilter(CorsFilter.java:33)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(Authentica
torBase.java:505)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:170)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:103)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:
956)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
a:423)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp
11Processor.java:1079)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(
AbstractProtocol.java:625)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpo
int.java:2522)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoin
t.java:2511)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.
java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
.java:615)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskTh
read.java:61)
at java.lang.Thread.run(Thread.java:745)
Caused by: com.alibaba.druid.pool.GetConnectionTimeoutException: wait millis 400
0, active 8, maxActive 8
at com.alibaba.druid.pool.DruidDataSource.getConnectionInternal(DruidDat
aSource.java:1139)
at com.alibaba.druid.pool.DruidDataSource.getConnectionDirect(DruidDataS
ource.java:960)
at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.
java:940)
at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.
java:930)
at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.
java:102)
at org.nutz.dao.impl.sql.run.NutDaoRunner.run(NutDaoRunner.java:59)
... 51 more
08:58:48 [DEBUG] org.nutz.mvc.impl.UrlMappingImpl - Found mapping for [POST] pat
h=/appModel/getAppModelData : AppModelAction.getAppModelData(...)
08:58:48 [DEBUG] org.nutz.ioc.impl.NutIoc - Get 'appModelAction'<class com.efrai
ser.ews.action.AppModelAction>
08:58:48 [DEBUG] org.nutz.dao.impl.sql.run.NutDaoExecutor - SELECT * FROM MODEL
WHERE id=?
| 1 |
|----------------------------------|
| f0885644f05440c797339de1b51aa727 |
For example:> "SELECT * FROM MODEL WHERE id='f0885644f05440c797339de1b51aa727
'"
08:58:48 [DEBUG] org.nutz.mvc.impl.UrlMappingImpl - Found mapping for [POST] pat
h=/appModel/getAppModelData : AppModelAction.getAppModelData(...)
08:58:48 [DEBUG] org.nutz.ioc.impl.NutIoc - Get 'appModelAction'<class com.efrai
ser.ews.action.AppModelAction>
08:58:48 [DEBUG] org.nutz.dao.impl.sql.run.NutDaoExecutor - SELECT * FROM MODEL
WHERE id=?
| 1 |
|----------------------------------|
| 0bce9561924b46bf96bb52eff4e08dab |
For example:> "SELECT * FROM MODEL WHERE id='0bce9561924b46bf96bb52eff4e08dab
'"