java - Issue with DB connection through JDBC -


 <!-- xml configs follows -->     <named-config name="mysql">         <property name="driverclass">com.mysql.jdbc.driver</property>         <property name="jdbcurl">jdbc:mysql://localhost:3306/jdbcstudy</property>         <property name="user">root</property>         <property name="password">root</property>          <property name="acquireincrement">5</property>         <property name="initialpoolsize">10</property>         <property name="minpoolsize">5</property>         <property name="maxpoolsize">20</property>     </named-config> 

dbutilsupdate.class

package com.itheima.dbutils;  import java.sql.connection; import java.sql.preparedstatement; import java.sql.resultset;  import org.apache.commons.dbutils.dbutils; import org.junit.test;  import com.mchange.v2.c3p0.combopooleddatasource;  public class dbutilsupdate {     @test     public void update1(){         connection conn = null;         preparedstatement ps = null;         resultset rs = null;             //get date source         combopooleddatasource source = new combopooleddatasource();         try {             conn = source.getconnection();             ps = conn.preparestatement("update account set money=?where name=?");             ps.setdouble(1, 999);             ps.setstring(2, "aaa");             ps.executequery();         } catch (exception e) {             e.printstacktrace();         } finally{             dbutils.closequietly(conn, ps, rs);         }     } }  database : create table account(     id int primary key auto_increment,     name varchar(20),     password double ) 

error:

those whole error: 2015-4-1 15:18:22 com.mchange.v2.log.mlog 信息: mlog clients using java 1.4+ standard logging. 2015-4-1 15:18:22 com.mchange.v2.c3p0.c3p0registry banner 信息: initializing c3p0-0.9.1.2 [built 21-may-2007 15:04:56; debug? true; trace: 10] 2015-4-1 15:18:22 com.mchange.v2.c3p0.impl.abstractpoolbackeddatasource getpoolmanager 信息: initializing c3p0 pool... com.mchange.v2.c3p0.combopooleddatasource [ acquireincrement -> 3, acquireretryattempts -> 30, acquireretrydelay -> 1000, autocommitonclose -> false, automatictesttable -> null, breakafteracquirefailure -> false, checkouttimeout -> 0, connectioncustomizerclassname -> null, connectiontesterclassname -> com.mchange.v2.c3p0.impl.defaultconnectiontester, datasourcename -> wetmww98w558pm19wrp3o|1cfb549, debugunreturnedconnectionstacktraces -> false, description -> null, driverclass -> null, factoryclasslocation -> null, forceignoreunresolvedtransactions -> false, identitytoken -> wetmww98w558pm19wrp3o|1cfb549, idleconnectiontestperiod -> 0, initialpoolsize -> 3, jdbcurl -> null, maxadministrativetasktime -> 0, maxconnectionage -> 0, maxidletime -> 0, maxidletimeexcessconnections -> 0, maxpoolsize -> 15, maxstatements -> 0, maxstatementsperconnection -> 0, minpoolsize -> 3, numhelperthreads -> 3, numthreadsawaitingcheckoutdefaultuser -> 0, preferredtestquery -> null, properties -> {}, propertycycle -> 0, testconnectiononcheckin -> false, testconnectiononcheckout -> false, unreturnedconnectiontimeout -> 0, usestraditionalreflectiveproxies -> false ] 2015-4-1 15:18:51 com.mchange.v2.resourcepool.basicresourcepool$acquiretask run 警告: com.mchange.v2.resourcepool.basicresourcepool$acquiretask@166a22b -- acquisition attempt failed!!! clearing pending acquires. while trying acquire needed new resource, failed succeed more maximum number of allowed acquisition attempts (30). last acquisition attempt exception: java.lang.nullpointerexception @ sun.jdbc.odbc.jdbcodbcdriver.getprotocol(jdbcodbcdriver.java:507) @ sun.jdbc.odbc.jdbcodbcdriver.knownurl(jdbcodbcdriver.java:476) @ sun.jdbc.odbc.jdbcodbcdriver.acceptsurl(jdbcodbcdriver.java:307) @ java.sql.drivermanager.getdriver(drivermanager.java:253) @ com.mchange.v2.c3p0.drivermanagerdatasource.driver(drivermanagerdatasource.java:223) @ com.mchange.v2.c3p0.drivermanagerdatasource.getconnection(drivermanagerdatasource.java:119) @ com.mchange.v2.c3p0.wrapperconnectionpooldatasource.getpooledconnection(wrapperconnectionpooldatasource.java:143) @ com.mchange.v2.c3p0.wrapperconnectionpooldatasource.getpooledconnection(wrapperconnectionpooldatasource.java:132) @ com.mchange.v2.c3p0.impl.c3p0pooledconnectionpool$1pooledconnectionresourcepoolmanager.acquireresource(c3p0pooledconnectionpool.java:137) @ com.mchange.v2.resourcepool.basicresourcepool.doacquire(basicresourcepool.java:1014) @ com.mchange.v2.resourcepool.basicresourcepool.access$800(basicresourcepool.java:32) @ com.mchange.v2.resourcepool.basicresourcepool$acquiretask.run(basicresourcepool.java:1810) @ com.mchange.v2.async.threadpoolasynchronousrunner$poolthread.run(threadpoolasynchronousrunner.java:547) 2015-4-1 15:18:51 com.mchange.v2.resourcepool.basicresourcepool$acquiretask run 警告: com.mchange.v2.resourcepool.basicresourcepool$acquiretask@47393f -- acquisition attempt failed!!! clearing pending acquires. while trying acquire needed new resource, failed succeed more maximum number of allowed acquisition attempts (30). last acquisition attempt exception: java.lang.nullpointerexception @ sun.jdbc.odbc.jdbcodbcdriver.getprotocol(jdbcodbcdriver.java:507) @ sun.jdbc.odbc.jdbcodbcdriver.knownurl(jdbcodbcdriver.java:476) @ sun.jdbc.odbc.jdbcodbcdriver.acceptsurl(jdbcodbcdriver.java:307) @ java.sql.drivermanager.getdriver(drivermanager.java:253) @ com.mchange.v2.c3p0.drivermanagerdatasource.driver(drivermanagerdatasource.java:223) @ com.mchange.v2.c3p0.drivermanagerdatasource.getconnection(drivermanagerdatasource.java:119) @ com.mchange.v2.c3p0.wrapperconnectionpooldatasource.getpooledconnection(wrapperconnectionpooldatasource.java:143) @ com.mchange.v2.c3p0.wrapperconnectionpooldatasource.getpooledconnection(wrapperconnectionpooldatasource.java:132) @ com.mchange.v2.c3p0.impl.c3p0pooledconnectionpool$1pooledconnectionresourcepoolmanager.acquireresource(c3p0pooledconnectionpool.java:137) @ com.mchange.v2.resourcepool.basicresourcepool.doacquire(basicresourcepool.java:1014) @ com.mchange.v2.resourcepool.basicresourcepool.access$800(basicresourcepool.java:32) @ com.mchange.v2.resourcepool.basicresourcepool$acquiretask.run(basicresourcepool.java:1810) @ com.mchange.v2.async.threadpoolasynchronousrunner$poolthread.run(threadpoolasynchronousrunner.java:547) 2015-4-1 15:18:51 com.mchange.v2.resourcepool.basicresourcepool$acquiretask run 警告: com.mchange.v2.resourcepool.basicresourcepool$acquiretask@120cc56 -- acquisition attempt failed!!! clearing pending acquires. while trying acquire needed new resource, failed succeed more maximum number of allowed acquisition attempts (30). last acquisition attempt exception: java.lang.nullpointerexception @ sun.jdbc.odbc.jdbcodbcdriver.getprotocol(jdbcodbcdriver.java:507) @ sun.jdbc.odbc.jdbcodbcdriver.knownurl(jdbcodbcdriver.java:476) @ sun.jdbc.odbc.jdbcodbcdriver.acceptsurl(jdbcodbcdriver.java:307) @ java.sql.drivermanager.getdriver(drivermanager.java:253) @ com.mchange.v2.c3p0.drivermanagerdatasource.driver(drivermanagerdatasource.java:223) @ com.mchange.v2.c3p0.drivermanagerdatasource.getconnection(drivermanagerdatasource.java:119) @ com.mchange.v2.c3p0.wrapperconnectionpooldatasource.getpooledconnection(wrapperconnectionpooldatasource.java:143) @ com.mchange.v2.c3p0.wrapperconnectionpooldatasource.getpooledconnection(wrapperconnectionpooldatasource.java:132) @ com.mchange.v2.c3p0.impl.c3p0pooledconnectionpool$1pooledconnectionresourcepoolmanager.acquireresource(c3p0pooledconnectionpool.java:137) @ com.mchange.v2.resourcepool.basicresourcepool.doacquire(basicresourcepool.java:1014) @ com.mchange.v2.resourcepool.basicresourcepool.access$800(basicresourcepool.java:32) @ com.mchange.v2.resourcepool.basicresourcepool$acquiretask.run(basicresourcepool.java:1810) @ com.mchange.v2.async.threadpoolasynchronousrunner$poolthread.run(threadpoolasynchronousrunner.java:547)

if use following codes ,the error not appear,but don't know why.

combopooleddatasource source = new combopooleddatasource();             source.setdriverclass("com.mysql.jdbc.driver");             source.setjdbcurl("jdbc:mysql:///jdbcstudy");             source.setuser("root");             source.setpassword("root");  


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -