用c3p0出问题了,别人的电脑可以发布并且运行,我的电脑却不行

chf199499 2016-08-16 06:38:55
myeclipse其他工程都能运行的,就今天在学c3p0的东西,一直报错,工程和数据库给朋友,朋友电脑上能运行,没问题,我发下错误

八月 16, 2016 6:32:54 下午 com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask run
警告: com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@34b57546 -- Acquisition Attempt Failed!!! Clearing pending acquires. While trying to acquire a needed new resource, we failed to succeed more than the maximum number of allowed acquisition attempts (30). Last acquisition attempt exception:
java.lang.NullPointerException
at sun.jdbc.odbc.JdbcOdbcDriver.getProtocol(JdbcOdbcDriver.java:524)
at sun.jdbc.odbc.JdbcOdbcDriver.knownURL(JdbcOdbcDriver.java:493)
at sun.jdbc.odbc.JdbcOdbcDriver.acceptsURL(JdbcOdbcDriver.java:307)
at java.sql.DriverManager.getDriver(DriverManager.java:262)
at com.mchange.v2.c3p0.DriverManagerDataSource.driver(DriverManagerDataSource.java:228)
at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:119)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:143)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:132)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:152)
at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1074)
at com.mchange.v2.resourcepool.BasicResourcePool.doAcquireAndDecrementPendingAcquiresWithinLockOnSuccess(BasicResourcePool.java:1061)
at com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:32)
at com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.run(BasicResourcePool.java:1796)
at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:620)
八月 16, 2016 6:32:54 下午 com.mchange.v2.resourcepool.BasicResourcePool forceKillAcquires
警告: Having failed to acquire a resource, com.mchange.v2.resourcepool.BasicResourcePool@23f3c60c is interrupting all Threads waiting on a resource to check out. Will try again in response to new client requests.
八月 16, 2016 6:32:54 下午 com.mchange.v2.resourcepool.BasicResourcePool forceKillAcquires
警告: Having failed to acquire a resource, com.mchange.v2.resourcepool.BasicResourcePool@23f3c60c is interrupting all Threads waiting on a resource to check out. Will try again in response to new client requests.
八月 16, 2016 6:32:54 下午 com.mchange.v2.resourcepool.BasicResourcePool forceKillAcquires
警告: Having failed to acquire a resource, com.mchange.v2.resourcepool.BasicResourcePool@23f3c60c is interrupting all Threads waiting on a resource to check out. Will try again in response to new client requests.
八月 16, 2016 6:32:54 下午 org.apache.catalina.core.StandardWrapperValve invoke
严重: Servlet.service() for servlet ListPrivilegeServlet threw exception
java.lang.RuntimeException: java.sql.SQLException: Connections could not be acquired from the underlying database!
at cn.itcast.dao.PrivilegeDao.getAll(PrivilegeDao.java:48)
at cn.itcast.service.SecurityService.getAllPrivilege(SecurityService.java:25)
at cn.itcast.web.controller.ListPrivilegeServlet.doGet(ListPrivilegeServlet.java:19)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:879)
at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:610)
at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1777)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.sql.SQLException: Connections could not be acquired from the underlying database!
at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:106)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:615)
at com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.getConnection(AbstractPoolBackedDataSource.java:128)
at org.apache.commons.dbutils.AbstractQueryRunner.prepareConnection(AbstractQueryRunner.java:156)
at org.apache.commons.dbutils.QueryRunner.query(QueryRunner.java:303)
at cn.itcast.dao.PrivilegeDao.getAll(PrivilegeDao.java:44)
... 16 more
Caused by: com.mchange.v2.resourcepool.CannotAcquireResourceException: A ResourcePool could not acquire a resource from its primary factory or source.
at com.mchange.v2.resourcepool.BasicResourcePool.awaitAvailable(BasicResourcePool.java:1406)
at com.mchange.v2.resourcepool.BasicResourcePool.prelimCheckoutResource(BasicResourcePool.java:594)
at com.mchange.v2.resourcepool.BasicResourcePool.checkoutResource(BasicResourcePool.java:514)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutAndMarkConnectionInUse(C3P0PooledConnectionPool.java:681)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:608)
... 20 more
...全文
298 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
chf199499 2016-08-27
  • 打赏
  • 举报
回复
引用 1 楼 Qrcode2 的回复:
1,驱动配置有误:driver=com.mysql.jdbc.Driver 2,数据库连接地址有误:url=jdbc:mysql://localhost:3306/test?3useUnicode=true&characterEncoding=utf8 3,密码或帐号有误:username=root password=root 4,数据库未启动或无权访问 5,项目未引入对应的驱动jar包mysql-connector-java-5.1.6-bin.jar 6,mysql root没有远程访问的权限,需要增加权限,增加权限的步骤如下: 进入mysql数据库: grant all privileges on *.* to 'root'@'%' identified by 'root' with grant option; flush privileges; 很有可能是5 引起的
不好意思这么晚才回, 后来发现是因为配置c3p0时没有默认配置,只有一个命名为mysql的配置,但是指定DataSource的时候忘记指定配置名称,所以出错了,还是不够细心啊。 private static DataSource ds = null; static{ ds = new ComboPooledDataSource("mysql"); }
java竹雨 2016-08-22
  • 打赏
  • 举报
回复
这事数据库设置的问题 和才c3p0没关系 你要在url加上grant all privileges on *.* to 'root'@'%' identified by 'root' with grant option;这个
wrong1111 2016-08-22
  • 打赏
  • 举报
回复
While trying to acquire a needed new resource, we failed to succeed more than the maximum number of allowed acquisition attempts (30).

楼主翻译下这句话,就明白问题了。。
子木 2016-08-21
  • 打赏
  • 举报
回复
如果网上的各种方法解决不了问题。请换掉c3p0,改成dbcp连接池,c3p0本身存在bug,目前并没有实质性的解决方案
Qrcode2 2016-08-19
  • 打赏
  • 举报
回复
tomcat下的lib目录加个jar包mysql-connector-java-5.1.6-bin.jar
Qrcode2 2016-08-19
  • 打赏
  • 举报
回复
1,驱动配置有误:driver=com.mysql.jdbc.Driver 2,数据库连接地址有误:url=jdbc:mysql://localhost:3306/test?3useUnicode=true&characterEncoding=utf8 3,密码或帐号有误:username=root password=root 4,数据库未启动或无权访问 5,项目未引入对应的驱动jar包mysql-connector-java-5.1.6-bin.jar 6,mysql root没有远程访问的权限,需要增加权限,增加权限的步骤如下: 进入mysql数据库: grant all privileges on *.* to 'root'@'%' identified by 'root' with grant option; flush privileges; 很有可能是5 引起的

81,094

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧