使用c3p0连接池是出现了空指针异常

连接不上我的mysql数据库,但是我单独测试又可以连接上,测试代码如下:

Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
try {
Class.forName("com.mysql.jdbc.Driver");
String url = "jdbc:mysql://localhost:3306/shi";
String name = "root";
String password = "root";
conn = DriverManager.getConnection(url, name, password);
String sql = "select * from t_user";
stmt = conn.createStatement();
rs = stmt.executeQuery(sql);
while(rs.next()) {
String username = rs.getString("name");
System.out.println(username);
}

    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    } catch (SQLException e) {
        e.printStackTrace();
    } finally {
        if(rs != null) {
            try {
                rs.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }

        if(stmt != null) {
            try {
                stmt.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }

        if(rs != null) {
            try {
                rs.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
    }

但是使用c3p0的时候就出问题了:
c3p0的配置如下:

<?xml version="1.0" encoding="UTF-8"?>

    <property name="jdbcUrl">jdbc:mysql://localhost:3306/shi?useUnicode=true&amp;characterEncoding=utf8</property>
    <property name="driverClass">com.mysql.jdbc.Driver</property>
    <property name="user">root</property>
    <property name="password">root</property>
    <!--  
    <property name="jdbcUrl">jdbc:oracle:thin:@localhost:1521:orcl</property>
    <property name="driverClass">oracle.jdbc.driver.OracleDriver</property>
    <property name="user">scott</property>
    <property name="password">tiger</property>
    -->

    <property name="c3p0.testConnectionOnCheckout">true</property>
    <property name="acquireIncrement">3</property>
    <property name="initialPoolSize">10</property>
    <property name="minPoolSize">2</property>
    <property name="maxPoolSize">10</property>
</default-config>

出现的异常如下:

kate
Tom

2014-8-9 9:31:05 com.mchange.v2.log.MLog
信息: MLog clients using java 1.4+ standard logging.
2014-8-9 9:31:06 com.mchange.v2.c3p0.C3P0Registry
信息: Initializing c3p0-0.9.5-pre8 [built 04-April-2014 04:20:15 -0700; debug? true; trace: 10]
2014-8-9 9:31:06 com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource
信息: 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, contextClassLoaderSource -> caller, dataSourceName -> 2sa1hd931f5tqer1kt6lht|2c766a24, debugUnreturnedConnectionStackTraces -> false, description -> null, driverClass -> null, extensions -> {}, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, forceUseNamedDriverClass -> false, identityToken -> 2sa1hd931f5tqer1kt6lht|2c766a24, idleConnectionTestPeriod -> 0, initialPoolSize -> 3, jdbcUrl -> null, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 0, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 15, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 3, numHelperThreads -> 3, preferredTestQuery -> null, privilegeSpawnedThreads -> false, properties -> {}, propertyCycle -> 0, statementCacheNumDeferredCloseThreads -> 0, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, unreturnedConnectionTimeout -> 0, userOverrides -> {}, usesTraditionalReflectiveProxies -> false ]
2014-8-9 9:31:36 com.mchange.v2.resourcepool.BasicResourcePool
警告: com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@6c3b78cf -- 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:507)
at sun.jdbc.odbc.JdbcOdbcDriver.knownURL(JdbcOdbcDriver.java:476)
at sun.jdbc.odbc.JdbcOdbcDriver.acceptsURL(JdbcOdbcDriver.java:307)
at java.sql.DriverManager.getDriver(DriverManager.java:253)
at com.mchange.v2.c3p0.DriverManagerDataSource.driver(DriverManagerDataSource.java:278)
at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:158)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:161)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:147)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:200)
at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1086)
at com.mchange.v2.resourcepool.BasicResourcePool.doAcquireAndDecrementPendingAcquiresWithinLockOnSuccess(BasicResourcePool.java:1073)
at com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:44)
at com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.run(BasicResourcePool.java:1814)
at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:696)
2014-8-9 9:31:36 com.mchange.v2.resourcepool.BasicResourcePool
警告: Having failed to acquire a resource, com.mchange.v2.resourcepool.BasicResourcePool@5c1fe88d is interrupting all Threads waiting on a resource to check out. Will try again in response to new client requests.
2014-8-9 9:31:36 com.mchange.v2.resourcepool.BasicResourcePool
警告: com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@53416c84 -- 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:507)
at sun.jdbc.odbc.JdbcOdbcDriver.knownURL(JdbcOdbcDriver.java:476)
at sun.jdbc.odbc.JdbcOdbcDriver.acceptsURL(JdbcOdbcDriver.java:307)
at java.sql.DriverManager.getDriver(DriverManager.java:253)
at com.mchange.v2.c3p0.DriverManagerDataSource.driver(DriverManagerDataSource.java:278)
at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:158)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:161)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:147)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:200)
at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1086)
at com.mchange.v2.resourcepool.BasicResourcePool.doAcquireAndDecrementPendingAcquiresWithinLockOnSuccess(BasicResourcePool.java:1073)
at com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:44)
at com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.run(BasicResourcePool.java:1814)
at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:696)
java.sql.SQLException: Connections could not be acquired from the underlying database!
at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:118)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:690)
at com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.getConnection(AbstractPoolBackedDataSource.java:140)
at jdbcUtils.JdbcUtils.getConnection(JdbcUtils.java:44)
at jdbcUtils.TestUtils.main(TestUtils.java:59)
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:1422)
at com.mchange.v2.resourcepool.BasicResourcePool.prelimCheckoutResource(BasicResourcePool.java:606)
at com.mchange.v2.resourcepool.BasicResourcePool.checkoutResource(BasicResourcePool.java:526)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutAndMarkConnectionInUse(C3P0PooledConnectionPool.java:756)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:683)
... 3 more
2014-8-9 9:31:36 com.mchange.v2.resourcepool.BasicResourcePool
警告: Having failed to acquire a resource, com.mchange.v2.resourcepool.BasicResourcePool@5c1fe88d is interrupting all Threads waiting on a resource to check out. Will try again in response to new client requests.
2014-8-9 9:31:36 com.mchange.v2.resourcepool.BasicResourcePool
警告: com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@58a2353d -- 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:507)
at sun.jdbc.odbc.JdbcOdbcDriver.knownURL(JdbcOdbcDriver.java:476)
at sun.jdbc.odbc.JdbcOdbcDriver.acceptsURL(JdbcOdbcDriver.java:307)
at java.sql.DriverManager.getDriver(DriverManager.java:253)
at com.mchange.v2.c3p0.DriverManagerDataSource.driver(DriverManagerDataSource.java:278)
at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:158)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:161)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:147)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:200)
at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1086)
at com.mchange.v2.resourcepool.BasicResourcePool.doAcquireAndDecrementPendingAcquiresWithinLockOnSuccess(BasicResourcePool.java:1073)
at com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:44)
at com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.run(BasicResourcePool.java:1814)
at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:696)
2014-8-9 9:31:36 com.mchange.v2.resourcepool.BasicResourcePool
警告: Having failed to acquire a resource, com.mchange.v2.resourcepool.BasicResourcePool@5c1fe88d is interrupting all Threads waiting on a resource to check out. Will try again in response to new client requests.

1个回答

请问这个问题是怎么解决的

weixin_43955357
Ni若白CE 我也是出现了这个问题
4 天之前 回复
Mr_faded
Mr_faded 请问楼主是怎么解决这个问题的呢??
2 年多之前 回复
qq_30936759
李小哥 你的这个问题是如何解决的
3 年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
c3p0连接池 无需关注statement是否关闭吗

c3p0连接池 ,当connection.close()的时候,把数据连接还回连接池中,那么connection所产生的statement,resultset等对象是怎么关闭的?

c3p0连接池使用,一直在打印无用日志,好像是一直在创建并销毁连接

使用C3p0连接池时,在空闲状态一直DEBUG打印如下日志,好像是一直在创建并销毁连接,要怎样配置才能够不一直创建销毁,创建后就保留起,如果连接不够再创建。 DEBUG c.m.v.resourcepool.BasicResourcePool - Preparing to destroy resource: com.mchange.v2.c3p0.impl.NewPooledConnection@4ae0cd66 DEBUG c.m.v.c.i.C3P0PooledConnectionPool - Preparing to destroy PooledConnection: com.mchange.v2.c3p0.impl.NewPooledConnection@4ae0cd66 DEBUG c.m.v.c.i.C3P0PooledConnectionPool - Successfully destroyed PooledConnection: com.mchange.v2.c3p0.impl.NewPooledConnection@4ae0cd66 DEBUG c.m.v.resourcepool.BasicResourcePool - Successfully destroyed resource: com.mchange.v2.c3p0.impl.NewPooledConnection@4ae0cd66 DEBUG c.m.v.resourcepool.BasicResourcePool - Checking for expired resources - Fri Sep 27 16:18:25 CST 2019 [com.mchange.v2.resourcepool.BasicResourcePool@2794eab6] DEBUG c.m.v.resourcepool.BasicResourcePool - BEGIN check for expired resources. [com.mchange.v2.resourcepool.BasicResourcePool@2794eab6] DEBUG c.m.v.resourcepool.BasicResourcePool - FINISHED check for expired resources. [com.mchange.v2.resourcepool.BasicResourcePool@2794eab6] DEBUG c.m.v.resourcepool.BasicResourcePool - Checking for expired resources - Fri Sep 27 16:18:26 CST 2019 [com.mchange.v2.resourcepool.BasicResourcePool@2794eab6] DEBUG c.m.v.resourcepool.BasicResourcePool - BEGIN check for expired resources. [com.mchange.v2.resourcepool.BasicResourcePool@2794eab6] DEBUG c.m.v.resourcepool.BasicResourcePool - EXPIRED idle resource: com.mchange.v2.c3p0.impl.NewPooledConnection@34b92a30 ---> idle_time: 1966; max_idle_time: 1000 [com.mchange.v2.resourcepool.BasicResourcePool@2794eab6] DEBUG c.m.v.resourcepool.BasicResourcePool - Removing expired resource: com.mchange.v2.c3p0.impl.NewPooledConnection@34b92a30 [com.mchange.v2.resourcepool.BasicResourcePool@2794eab6] DEBUG c.m.v.resourcepool.BasicResourcePool - FINISHED check for expired resources. [com.mchange.v2.resourcepool.BasicResourcePool@2794eab6] DEBUG c.m.v.resourcepool.BasicResourcePool - Preparing to destroy resource: com.mchange.v2.c3p0.impl.NewPooledConnection@34b92a30 DEBUG c.m.v.c.i.C3P0PooledConnectionPool - Preparing to destroy PooledConnection: com.mchange.v2.c3p0.impl.NewPooledConnection@34b92a30 DEBUG c.m.v.c.i.C3P0PooledConnectionPool - Successfully destroyed PooledConnection: com.mchange.v2.c3p0.impl.NewPooledConnection@34b92a30 DEBUG c.m.v.resourcepool.BasicResourcePool - Successfully destroyed resource: com.mchange.v2.c3p0.impl.NewPooledConnection@34b92a30

Android 中使用c3p0连接池报错,错误: 无法访问Referenceable

Android 中使用c3p0连接池报错,错误: 无法访问Referenceable,该如何解决,有没有大神使用过![图片说明](https://img-ask.csdn.net/upload/202003/28/1585385580_936349.jpg)

求一个并发量在100以上的c3p0连接池配置

求一个并发量在100以上的c3p0连接池配置 现在是用jdbc可以达到50个以上的并发

Hibernate配置C3P0连接池报错

Hibernate+MySQL部署出现了java.net.SocketException: Broken pipe (Write failed)这个错误,查百度说是因为MySQL默认连接8小时的问题,所以想采用C3P0,附上Hibernate.xml配置如下: ``` <?xml version='1.0' encoding='UTF-8'?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"> <!-- Generated by MyEclipse Hibernate Tools. --> <hibernate-configuration> <session-factory> <property name="myeclipse.connection.profile">sces</property> <property name="connection.url"><![CDATA[jdbc:mysql://localhost:3306/sces?useUnicode=true&characterEncoding=UTF-8]]></property> <property name="connection.driver_class">com.mysql.jdbc.Driver</property> <property name="dialect"> org.hibernate.dialect.MySQLDialect </property> <property name="connection.password">123456</property> <property name="connection.username">root</property> <!--c3p0设置--> <!--<property name="connection.provider_class">org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider</property>--> <!--<property name="hibernate.c3p0.min_size">5</property>--> <!--<property name="hibernate.c3p0.max_size">20</property>--> <!--<property name="hibernate.c3p0.max_statements">100</property>--> <!--<property name="hibernate.c3p0.timeout">3600</property>--> <!--<property name="hibernate.c3p0.idle_test_period">120</property>--> <!--<property name="hibernate.c3p0.acquire_increment">2</property>--> <mapping resource="entity/DCharacteristic.hbm.xml" /> <mapping resource="entity/DIops.hbm.xml" /> <mapping resource="entity/DPool.hbm.xml" /> <mapping resource="entity/DStatus.hbm.xml" /> <mapping resource="entity/Device.hbm.xml" /> <mapping resource="entity/User.hbm.xml" /> <mapping resource="entity/DDl.hbm.xml" /> <mapping resource="entity/Systeminfo.hbm.xml" /> <mapping resource="entity/DCapacity.hbm.xml"/> <mapping resource="entity/DErrlog.hbm.xml"/> <mapping resource="entity/DRack.hbm.xml"/> </session-factory> </hibernate-configuration> ``` 中间注释掉的为c3p0的部分,现在这种情况下能正常运行,但是打开c3p0后会报错: ``` 十二月 26, 2017 3:02:49 下午 com.mchange.v2.resourcepool.BasicResourcePool 警告: com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@58f663e4 -- 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.sql.SQLException: No suitable driver at java.sql.DriverManager.getDriver(DriverManager.java:278) at com.mchange.v2.c3p0.DriverManagerDataSource.driver(DriverManagerDataSource.java:285) at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:175) at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:220) at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:206) at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:203) at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1138) at com.mchange.v2.resourcepool.BasicResourcePool.doAcquireAndDecrementPendingAcquiresWithinLockOnSuccess(BasicResourcePool.java:1125) at com.mchange.v2.resourcepool.BasicResourcePool.access$700(BasicResourcePool.java:44) at com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.run(BasicResourcePool.java:1870) at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:696) ``` 看起来是找不到驱动,但是明明不开连接池的时候能正常跑的,说明驱动没问题呀,为什么会这样呢 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 补充:直接在IDE中运行读取数据库的操作可以正常运行,但是把程序放到tomcat中就会 报这个错误,MySQL的驱动在tomcat的bin和lib中都放了,求解!!!!!

springnvc+mybatis+C3P0连接池,一段时间数据库就崩溃了,求援~

云服务上有三个tomcat服务器,都启动一段时间后报异常,mysql数据库崩溃,求帮助,怎么配置都配置不行 applicationcontext中连接池配置 ``` <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"> <property name="driverClass" value="${jdbc.driver}" /> <property name="jdbcUrl" value="${jdbc.url}" /> <property name="user" value="${jdbc.username}" /> <property name="password" value="${jdbc.password}" /> <!--连接池中保留的最小连接数。 --> <property name="minPoolSize" value="${minPoolSize}" /> <!--连接池中保留的最大连接数。Default: 15 --> <property name="maxPoolSize" value="${maxPoolSize}" /> <!--最大空闲时间,1800秒内未使用则连接被丢弃。若为0则永不丢弃。Default: 0 --> <property name="maxIdleTime" value="${maxIdleTime}" /> <!--当连接池中的连接耗尽的时候c3p0一次同时获取的连接数。Default: 3 --> <property name="acquireIncrement" value="${acquireIncrement}" /> <!--c3p0全局的PreparedStatements缓存的大小。如果maxStatements与maxStatementsPerConnection均为0,则缓存不生效,只要有一个不为0,则语句的缓存就能生效。如果默认值:0 --> <property name="maxStatements" value="${maxStatements}" /> <property name="initialPoolSize" value="${initialPoolSize}" /> <!--当连接池用完时客户端调用getConnection()后等待获取新连接的时间,如设为0则无限期等待。单位毫秒。Default: 0 --> <property name="checkoutTimeout" value="${checkoutTimeout}" /> <!--每60秒检查所有连接池中的空闲连接。Default: 0 --> <property name="idleConnectionTestPeriod" value="${idleConnectionTestPeriod}" /> <!--定义在从数据库获取新连接失败后重复尝试的次数。Default: 30 --> <property name="acquireRetryAttempts" value="${acquireRetryAttempts}" /> <property name="breakAfterAcquireFailure" value="${breakAfterAcquireFailure}" /> <property name="testConnectionOnCheckout" value="${testConnectionOnCheckout}" /> <property name="connectionCustomizerClassName" value="com.tanwuapp.util.handler.UTF8MB4ConnectionCustomizer" /> </bean> ``` ``` minPoolSize=10 <!--连接池中保留的最大连接数。Default: 15 --> maxPoolSize=40 <!--最大空闲时间,30秒内未使用则连接被丢弃。若为0则永不丢弃。Default: 0 --> maxIdleTime=30 <!--当连接池中的连接耗尽的时候c3p0一次同时获取的连接数。Default: 3 --> acquireIncrement=3 <!--c3p0全局的PreparedStatements缓存的大小。如果maxStatements与maxStatementsPerConnection均为0,则缓存不生效,只要有一个不为0,则语句的缓存就能生效。如果默认值: 0--> maxStatements=50 <!--maxStatementsPerConnection定义了连接池内单个连接所拥有的最大缓存statements数。默认值: 0 --> maxStatementsPerConnection=0 initialPoolSize=10 <!--当连接池用完时客户端调用getConnection()后等待获取新连接的时间,如设为0则无限期等待。单位毫秒。Default: 0 --> checkoutTimeout=10000 <!--每30秒检查所有连接池中的空闲连接。Default: 0 --> idleConnectionTestPeriod=30 <!--定义在从数据库获取新连接失败后重复尝试的次数。Default: 30 --> acquireRetryAttempts=30 breakAfterAcquireFailure=true testConnectionOnCheckout=false ``` 异常信息: ``` org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Communications link failure The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.) ### The error may exist in file [/home/webapps/tomcat-1.2.1/tanwuapps/TanWuAppAPI_v1.2.1/WEB-INF/classes/com/tanwuapp/dao/mapper/BasBannerMapper.xml] ### The error may involve com.tanwuapp.dao.BasBannerDao.findAllInfo ### The error occurred while executing a query ### Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Communications link failure The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.) at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:75) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:371) at com.sun.proxy.$Proxy9.selectList(Unknown Source) at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:198) at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:119) at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:63) at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:52) at com.sun.proxy.$Proxy42.findAllInfo(Unknown Source) at com.tanwuapp.service.impl.HomePageServiceImpl.getBannerList(HomePageServiceImpl.java:55) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:198) at com.sun.proxy.$Proxy46.getBannerList(Unknown Source) at com.tanwuapp.controller.ProductSearchController.searchHomeBannerData(ProductSearchController.java:78) at com.tanwuapp.controller.ProductSearchController$$FastClassBySpringCGLIB$$1b828f00.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:700) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150) at org.springframework.cache.interceptor.CacheInterceptor$1.invoke(CacheInterceptor.java:58) at org.springframework.cache.interceptor.CacheAspectSupport.execute(CacheAspectSupport.java:211) at org.springframework.cache.interceptor.CacheInterceptor.invoke(CacheInterceptor.java:66) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:633) at com.tanwuapp.controller.ProductSearchController$$EnhancerBySpringCGLIB$$f6dc0725.searchHomeBannerData(<generated>) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:219) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:745) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:686) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:953) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:855) at javax.servlet.http.HttpServlet.service(HttpServlet.java:650) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:829) at javax.servlet.http.HttpServlet.service(HttpServlet.java:731) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:436) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1078) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316) 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(TaskThread.java:61) at java.lang.Thread.run(Thread.java:745) Caused by: org.apache.ibatis.exceptions.PersistenceException: ```

创建c3p0连接池的原理

``` public class JdbcUtils { private static DataSource dataSource; static { dataSource = new ComboPooledDataSource(); } public static DataSource getDataSource() { return dataSource; } public static QueryRunner queryRunner() { return new QueryRunner(dataSource); } } ``` 请问一下,就是这上面这一段代码为什么能够创建连接池,并且能够顺利连接上数据库呢?这一段时间,自己写小项目,见得比较多,但是其中的原理不明白,所以想请问一下。拜谢!

c3p0 连接数据库超时问题

我在工程里面使用c3p0做数据库连接池。在测试功能时平方重启应用。发现在重启时出现连接数据库超时。如果重新再重启应用将能够正常连接数据库。 提示超时的速度非常快,正常连接不上数据库会60秒后再提示连接超时。 是否有人遇到同样的问题? c3p0配置如下: ``` <property name="checkoutTimeout">30000</property> <property name="idleConnectionTestPeriod">1200</property> <property name="maxIdleTime">800</property> <property name="maxIdleTimeExcessConnections">120</property> <property name="maxConnectionAge">200</property> <property name="unreturnedConnectionTimeout">1000</property> <property name="maxPoolSize">300</property> <property name="minPoolSize">50</property> <property name="initialPoolSize">50</property> <property name="acquireIncrement">1</property> <property name="numHelperThreads">8</property> ```

c3p0连接池的无法获得连接对象,按照视频里添加里驱动程序仍然显示java.sql.SQLException: No suitable driver

![图片说明](https://img-ask.csdn.net/upload/201911/18/1574046716_109697.png) 我的服务器版本是8.0.12的,驱动jar包官网只能下在8.0.18的但是听说好像是向下兼容的 c3po的配置文件 ``` <?xml version="1.0" encoding="utf-8"?> <c3p0-config> <default-config> <property name="driverClass">com.mysql.jdbc.Driver</property> <property name="jdbcUrl">jdbc:mysql://localhost:3306/test</property> <property name="user">root</property> <property name="password">123456</property> <property name="initialPoolSize">5</property> <property name="maxPoolSize">10</property> <property name="checkoutTimeout">3000</property> </default-config> <named-config name="otherc3p0"> <property name="user">root</property> <property name="password">123456</property> <property name="jdbcUrl">jdbc:mysql://localhost:3306/test</property> <property name="driverClass">com.mysql.jdbc.Driver</property> <!-- 如果池中数据连接不够时一次增长多少个 --> <property name="acquireIncrement">5</property> <!-- 初始化数据库连接池时连接的数量 --> <property name="initialPoolSize">20</property> <!-- 数据库连接池中的最大的数据库连接数 --> <property name="maxPoolSize">25</property> <!-- 数据库连接池中的最小的数据库连接数 --> <property name="minPoolSize">5</property> <property name="checkoutTimeout">3000</property> </named-config> </c3p0-config> ``` 主程序 ``` package cn.HSY; import com.mchange.v2.c3p0.ComboPooledDataSource; import javax.sql.DataSource; import java.sql.Connection; import java.sql.SQLException; public class DataSoure01 { public static void main(String[] args) throws SQLException { DataSource dataSource=new ComboPooledDataSource(); Connection connection=dataSource.getConnection(); System.out.println(connection); } } ```

java项目Oracle数据库报c3p0连接池异常

项目上线了一段时间,这几天项目不停报这3个异常,数据库用的是Oracle,rac的链接方式,求解。。。 com.mchange.v2.resourcepool.BasicResourcePool@7c62432b -- Thread unexpectedly interrupted while performing an acquisition attempt. java.lang.InterruptedException: sleep interrupted Task com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@529306d1 (in deadlocked PoolThread) failed to complete in maximum t ime 60000ms. Trying interrupt(). com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector@7c6ab651 -- APPARENT DEADLOCK!!! Creating emergency threads for unassigned pending tasks! 数据库异常还引发了Quartz异常,Quartz用的是集群方式,依赖数据库,报了下面异常: quartz Handling the first 1 triggers that missed theif scheduled first-time. 求大神指教,万分感谢!!!

c3p0 连接不释放 请路过的大神过来看看

配置文件如下 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd"> <context:annotation-config /> <!-- 打开Spring的Annotation支持 --> <!-- 设定Spring 去哪些包中找Annotation --> <context:component-scan base-package="com.myd" /> <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close"> <property name="driverClass" value="${driverClass}" /> <property name="jdbcUrl" value="${jdbcUrl}" /> <property name="user" value="${username}" /> <property name="password" value="${password}" /> <!-- 配置连接池的初始值 --> <property name="acquireIncrement" value="${acquireIncrement}" /> <property name="maxPoolSize" value="${maxPoolSize}" /> <property name="minPoolSize" value="${minPoolSize}" /> <property name="initialPoolSize" value="${initialPoolSize}" /> <property name="maxIdleTime" value="${maxIdleTime}" /> <property name="checkoutTimeout" value="${checkoutTimeout}" /> <property name="autoCommitOnClose" value="${autoCommitOnClose}"></property> <property name="acquireRetryDelay" value="${acquireRetryDelay}" /> <property name="idleConnectionTestPeriod" value="${idleConnectionTestPeriod}"></property> <property name="maxStatements" value="${maxStatements}"></property> <property name="numHelperThreads" value="${numHelperThreads}"></property> </bean> <!-- 导入src目录下的c3p0.properties文件 --> <context:property-placeholder location="classpath:c3p0.properties" /> <!--创建Spring的SessionFactory工厂 --> <!-- 如果使用的是Annotation的方式,不能使用LocalSessionFactoryBean,而应该使用 org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean --> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> <!-- 注入数据源 --> <property name="dataSource" ref="dataSource" /> <!-- 设置Spring取那个包中查找相应的实体类 --> <property name="packagesToScan"> <value>com.myd.entity</value> </property> <property name="hibernateProperties"> <!-- <value> hibernate.dialect=org.hibernate.dialect.HSQLDialect </value> --> <props> <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop> <prop key="hibernate.show_sql">true</prop> <prop key="hibernate.hbm2ddl.auto">update</prop> <prop key="hibernate.format_sql">true</prop> <prop key="hibernate.autoReconnect">true</prop> <prop key="jdbc.use_scrollable_resultset">false</prop> <prop key="hibernate.connection.release_mode">after_statement</prop> <prop key="hibernate.c3p0.validate">true</prop> <prop key="hibernate.c3p0.idle_test_period">30</prop> <prop key="hibernate.c3p0.timeout">30</prop> <prop key="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</prop> </props> </property> </bean> <!-- 开启HibernateTemplate,并且为其注入SessionFactory 使用HibernateTemplate不太方便的就是要获取session得通过getSessionFactory()方法获取 --> <bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory" /> </bean> <!-- 配置Spring的事务处理 --> <!-- 创建事务管理器 --> <bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory" /> </bean> <!-- 配置AOP,Spring是通过AOP来进行事务管理的 --> <aop:config> <!-- 设置pointCut表示哪些方法要加入事务处理 --> <!-- 以下的事务是声明在DAO中,但是通常都会在Service来处理多个业务对象逻辑的关系,注入删除,更新等,此时如果在执行了一个步骤之后抛出异常 就会导致数据不完整,所以事务不应该在DAO层处理,而应该在service,这也就是Spring所提供的一个非常方便的工具,声明式事务 --> <aop:pointcut id="allMethods" expression="execution(* com.myd.service.*.*(..))" /> <!-- 通过advisor来确定具体要加入事务控制的方法 --> <aop:advisor advice-ref="txAdvice" pointcut-ref="allMethods" /> </aop:config> <!-- 配置哪些方法要加入事务控制 --> <tx:advice id="txAdvice" transaction-manager="txManager"> <tx:attributes> <!-- 让所有的方法都加入事务管理,为了提高效率,可以把一些查询之类的方法设置为只读的事务 --> <tx:method name="*" propagation="REQUIRED" read-only="true" /> <!-- 以下方法都是可能设计修改的方法,就无法设置为只读 --> <tx:method name="add*" propagation="REQUIRED" /> <tx:method name="del*" propagation="REQUIRED" /> <tx:method name="update*" propagation="REQUIRED" /> <tx:method name="save*" propagation="REQUIRED" /> </tx:attributes> </tx:advice> <bean id="taskExecutor" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor"> <property name="corePoolSize" value="5" /> <property name="maxPoolSize" value="50" /> <property name="queueCapacity" value="1000" /> <property name="keepAliveSeconds" value="60" /> </bean> </beans> 这是事务 package com.myd.dao.impl; import java.lang.reflect.ParameterizedType; import java.sql.SQLException; import java.util.Collection; import java.util.List; import java.util.Map; import java.util.Set; import javax.annotation.Resource; import org.hibernate.HibernateException; import org.hibernate.Query; import org.hibernate.SQLQuery; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.transform.Transformers; import org.springframework.dao.DataAccessResourceFailureException; import org.springframework.orm.hibernate3.support.HibernateDaoSupport; import org.springframework.stereotype.Repository; import com.myd.dao.BaseDao; /** * 可以考虑把所有公共的方法都写在baseDAo中,让所有的DAO都继承BaseDao * 这样基本上就实现了大量的基础方法,如果DAO中有逻辑处理特殊的方法,再在具体的实现类中的DAO中创建 * * @author Administrator * * @param <T> */ @Repository("baseDaoImpl") public class BaseDaoImpl<T> extends HibernateDaoSupport implements BaseDao<T> { /** * 此处不能使用setSessionFactory注入,因为setSessionFactory在HibernateDaoSupport * 中已经定义了而且还是final的,不能被覆盖 * * @param sessionFactory */ @Resource(name = "sessionFactory") public void setSuperSessionFactory(SessionFactory sessionFactory) { super.setSessionFactory(sessionFactory); } /** * 创建Class的对象来获取泛型的class */ private Class<Object> clz; @SuppressWarnings("unchecked") public Class<Object> getClz() { if (clz == null) { // 获取泛型的Class对象 clz = (Class<Object>) ((ParameterizedType) getClass() .getGenericSuperclass()).getActualTypeArguments()[0]; } return clz; } public void add(T t) { getHibernateTemplate().getSessionFactory().openSession(); getHibernateTemplate().save(t); getHibernateTemplate().getSessionFactory().close(); } public void delete(int id) { getHibernateTemplate().getSessionFactory().openSession(); getHibernateTemplate().delete(load(id)); getHibernateTemplate().getSessionFactory().close(); } @SuppressWarnings("deprecation") public void update(T t) { try { getHibernateTemplate().getSessionFactory().openSession() .connection().prepareStatement("SET SQL_SAFE_UPDATES=0") .execute(); } catch (DataAccessResourceFailureException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (HibernateException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalStateException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } getHibernateTemplate().update(t); getHibernateTemplate().getSessionFactory().close(); } 现在的问题是 运行一段时间后,就卡起, 不是报连接数据库关闭 就是 返回空指针 查了以下是连接未释放导致的,我想请教下各位大神 我这样连接没关闭并回到连接池吗?

C3p0连接可以设定最大连接数么?连接池中最多可以存在的连接个数?

C3p0连接可以设定最大连接数:连接池中最多可以存在的连接个数?如果没有这个参数,连接太多的话,数据库岂不承受不了。

c3p0 连接池异常,哪位大仙解决过

2017-04-13 01:11:45 NewPooledConnection:486 WARN - [c3p0] A PooledConnection that has already signalled a Connection error is still in use! 2017-04-13 01:11:45 NewPooledConnection:487 WARN - [c3p0] Another error has occurred [ java.sql.SQLException: Closed Connection ] which will not be reported to listeners! java.sql.SQLException: Closed Connection at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:145) at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:190) at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:286) at oracle.jdbc.driver.PhysicalConnection.setAutoCommit(PhysicalConnection.java:1213) at com.mchange.v2.c3p0.impl.NewProxyConnection.setAutoCommit(NewProxyConnection.java:881) at org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.releaseManagedConnection(JdbcTransaction.java:127) at org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.doRollback(JdbcTransaction.java:170) at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.rollback(AbstractTransactionImpl.java:211) at org.springframework.orm.hibernate4.HibernateTransactionManager.doRollback(HibernateTransactionManager.java:604) at org.springframework.transaction.support.AbstractPlatformTransactionManager.processRollback(AbstractPlatformTransactionManager.java:853) at org.springframework.transaction.support.AbstractPlatformTransactionManager.rollback(AbstractPlatformTransactionManager.java:830) at org.springframework.transaction.interceptor.TransactionAspectSupport.completeTransactionAfterThrowing(TransactionAspectSupport.java:503) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:285) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:655) at com.jm.application.service.impl.SysUserServiceImpl$$EnhancerBySpringCGLIB$$8703f6f2.getEntity(<generated>) at com.jm.application.controller.JfipayReceiveController.payReceive(JfipayReceiveController.java:78) at sun.reflect.GeneratedMethodAccessor50.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:222) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:814) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:737) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:969) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:871) at javax.servlet.http.HttpServlet.service(HttpServlet.java:650) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:845) at javax.servlet.http.HttpServlet.service(HttpServlet.java:731) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:121) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at com.jm.config.JM_Filter.doFilter(JM_Filter.java:68) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:436) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1078) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316) 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(TaskThread.java:61) at java.lang.Thread.run(Thread.java:745) 连接池配置 #default : 0 #配置当连接池所有连接用完时应用程序getConnection的等待时间。为0则无限等待直至有其他连接释放 #或者创建新的连接,不为0则当时间到的时候如果仍没有获得连接,则会抛出SQLException checkout.timeout=600000 #当连接池中的连接用完时,C3P0一次性创建新连接的数目 default : 3 acquireIncrement=20 #用来配置测试连接 preferredTestQuery=select 1 from dual #如果为true,则在close的时候测试连接的有效性 testConnectionOnCheckin=false #用来配置测试空闲连接的间隔时间,测试方式:preferredTestQuery或者automaticTestTable idleConnectionTestPeriod=3000000 #连接池在获得新连接失败时重试的次数,如果小于等于0则无限重试直至连接获得成功 acquireRetryAttempts=0 #default : 1000ms #连接池在获得新连接时的间隔时间 default : 1000 单位ms acquireRetryDelay=1000

struts配置c3p0连接池出错

希望在struts+hibernate的项目中既用struts的jdbc连接池又用hibernate的连接池,用dbcp可以同时使用,因为hibernate配置的是c3p0,所以想把struts连接池也用c3p0,在struts-config.xml中写下如下配置: <data-source key="datasource" type="com.mchange.v2.c3p0.ComboPooledDataSource"> <set-property property="password" value="abc" /> <set-property property="username" value="abc" /> <set-property property="driverClass" value="oracle.jdbc.driver.OracleDriver" /> <set-property property="jdbcUrl" value="jdbc:oracle:thin:@127.0.0.1:1521:test" /> <set-property property="minPoolSize" value="10" /> <set-property property="maxPoolSize" value="20" /> <set-property property="initialPoolSize" value="10" /> </data-source> 运行后报错: 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:529) at com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.getConnection(AbstractPoolBackedDataSource.java:128) at com.struts_learn.dao.ArticleDAO.delete(ArticleDAO.java:162) at com.struts_learn.action.ArticleManageAction.doAction(ArticleManageAction.java:47) at com.struts_learn.action.CommonAction.execute(CommonAction.java:24) at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431) at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196) at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432) at javax.servlet.http.HttpServlet.service(HttpServlet.java:709) at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157) at com.struts_learn.util.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:29) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520) at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929) at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705) at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683) at java.lang.Thread.run(Unknown Source) 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:1319) at com.mchange.v2.resourcepool.BasicResourcePool.prelimCheckoutResource(BasicResourcePool.java:557) at com.mchange.v2.resourcepool.BasicResourcePool.checkoutResource(BasicResourcePool.java:477) at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:525) ... 37 more [b]问题补充:[/b] 本地测试,肯定连接没超,我怀疑struts能不能用c3p0的连接池,如果能那就是配置错了..不过实在不知道错在哪,貌似没有人用struts+c3p0..

关于连接池和c3p0的问题

问题一:看了一些帖子说连接池是存放连接的,意思就是: 我创建了多个和数据源(mysql数据库)相连的链接,然后存放在连接池中,谁要是访问我的数据源(登录,注册等等动作)谁就拿一个链接,用完之后再放回连接池。 我理解的正确吗? 问题二:尝试了一下c3p0,感觉和以前做链接很不一样,以前做一个JDBCConnutil类,每个dao层中的类使用JDBCConn中的方法连接一次,c3p0和这个一样吗?为什么我连接不上。。

c3p0连接池问题

<p><span style="font-family: Helvetica, Tahoma, Arial, sans-serif; font-size: 14px; line-height: 25px; background-color: #efefef;">上网查找资料,发现很多人也遇到了"APPARENT DEADLOCK"的问题</span><span style="white-space: pre; background-color: #fafafa;">http://www.iteye.com/topic/1117330</span></p> <pre name="code" class="java">http://www.iteye.com/topic/71051 http://www.iteye.com/topic/22160 http://www.iteye.com/topic/87313 http://www.iteye.com/topic/429677 https://forum.hibernate.org/viewtopic.php?f=1&amp;t=947246&amp;sid=ad2b8cc3213c9dac834d81b55bbf6291 </pre> <p> </p> <p> </p> <p>以下是我在tomcat下跑的异常信息   请问怎么解决</p> <p>弄了好几天啦。真的是C3P0 bug吗</p> <p> </p> <pre name="code" class="java">2011-11-04 15:37:22,694 WARN com.mchange.v2.async.ThreadPoolAsynchronousRunner - com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector@6fd42b -- APPARENT DEADLOCK!!! Creating emergency threads for unassigned pending tasks! 2011-11-04 15:37:22,694 WARN com.mchange.v2.async.ThreadPoolAsynchronousRunner - com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector@6fd42b -- APPARENT DEADLOCK!!! Complete Status: Managed Threads: 3 Active Threads: 3 Active Tasks: com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@18be695 (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2) com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@1cf63de (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1) com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@a5b703 (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0) Pending Tasks: com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@192492a com.mchange.v2.resourcepool.BasicResourcePool$1RefurbishCheckinResourceTask@101935d com.mchange.v2.resourcepool.BasicResourcePool$1RefurbishCheckinResourceTask@71f06c Pool thread stack traces: Thread[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2,5,main] java.lang.Thread.sleep(Native Method) com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1805) com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547) Thread[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1,5,main] java.lang.Thread.sleep(Native Method) com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1805) com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547) Thread[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0,5,main] java.lang.Thread.sleep(Native Method) com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1805) com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547) 2011-11-04 15:37:28,123 WARN org.directwebremoting.dwrp.DefaultConverterManager - Clash of converters for com.forgon.oa.schedule.model.Schedule. Using org.directwebremoting.convert.BeanConverter in place of org.directwebremoting.convert.BeanConverter 2011-11-04 15:37:28,123 WARN org.directwebremoting.dwrp.DefaultConverterManager - Clash of converters for com.forgon.oa.schedule.model.RepeatRange. Using org.directwebremoting.convert.BeanConverter in place of org.directwebremoting.convert.BeanConverter 2011-11-04 15:37:28,123 WARN org.directwebremoting.dwrp.DefaultConverterManager - Clash of converters for com.forgon.csair.dutyreport.dutyreportmgr.model.PilotDuty. Using org.directwebremoting.convert.BeanConverter in place of org.directwebremoting.convert.BeanConverter 2011-11-04 15:37:28,123 WARN org.directwebremoting.dwrp.DefaultConverterManager - Clash of converters for com.csair.cmis.integermanagement.reservation.model.ReservationHandle. Using org.directwebremoting.convert.BeanConverter in place of org.directwebremoting.convert.BeanConverter 2011-11-04 15:37:28,169 ERROR org.directwebremoting.impl.SignatureParser - Unable to find method called: getViewTableList on type: com.forgon.knowledge.dwr.KnowledgeTableManager 2011-11-04 15:37:28,185 ERROR org.directwebremoting.impl.SignatureParser - Unable to find method called: getTemplateTableList on type: com.forgon.oa.dwr.table.TemplateTableManager 2011-11-04 15:37:28,201 ERROR org.directwebremoting.impl.SignatureParser - Unable to find method called: getLogTableList on type: com.forgon.log.dwr.table.LogTableManager 2011-11-04 15:37:28,232 ERROR org.directwebremoting.impl.SignatureParser - Parameter mismatch parsing signatures section in dwr.xml on line: FlowDefinitionTableManager.saveOrUpdateFromJs(FlowDefinition flowDefinition, List&lt;MyTaskNode&gt; nodeList, List&lt;Connection&gt; lineList) 2011-11-04 15:37:28,247 ERROR org.directwebremoting.impl.SignatureParser - Unable to find method called: getFlowDefinitionTableList on type: com.forgon.workflow.designer.dwr.table.FlowDefinitionTableManager 2011-11-04 15:37:34,472 WARN com.mchange.v2.resourcepool.BasicResourcePool - com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@a5b703 -- 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.sql.SQLException: Listener refused the connection with the following error: ORA-12500, TNS:listener failed to start a dedicated server process The Connection descriptor used by the client was: </pre> <pre name="code" class="java"> at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112) at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:261) at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:387) at oracle.jdbc.driver.PhysicalConnection.&lt;init&gt;(PhysicalConnection.java:441) at oracle.jdbc.driver.T4CConnection.&lt;init&gt;(T4CConnection.java:165) at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35) at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:801) at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:134) at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:182) at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:171) at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:137) at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1014) at com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:32) at com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1810) at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547) 2011-11-04 15:37:34,472 ERROR com.mchange.v2.resourcepool.BasicResourcePool - A RESOURCE POOL IS PERMANENTLY BROKEN! [com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@a5b703] 2011-11-04 15:37:34,472 ERROR com.mchange.v2.resourcepool.BasicResourcePool - com.mchange.v2.resourcepool.BasicResourcePool@2567a6 -- Unexpectedly broken!!! com.mchange.v2.resourcepool.ResourcePoolException: Unexpected Break Stack Trace! at com.mchange.v2.resourcepool.BasicResourcePool.unexpectedBreak(BasicResourcePool.java:866) at com.mchange.v2.resourcepool.BasicResourcePool.access$1100(BasicResourcePool.java:32) at com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1854) at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547) 2011-11-04 15:59:25,482 WARN com.mchange.v2.async.ThreadPoolAsynchronousRunner - com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector@121b9ea -- APPARENT DEADLOCK!!! Creating emergency threads for unassigned pending tasks! 2011-11-04 15:59:25,482 WARN com.mchange.v2.async.ThreadPoolAsynchronousRunner - com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector@121b9ea -- APPARENT DEADLOCK!!! Complete Status: Managed Threads: 3 Active Threads: 3 Active Tasks: com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@134c6be (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1) com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@1e417da (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0) com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@1da208c (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2) Pending Tasks: com.mchange.v2.resourcepool.BasicResourcePool$1DestroyResourceTask@18eee3b com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@ba9379 Pool thread stack traces: Thread[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1,5,main] java.lang.Thread.sleep(Native Method) com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1805) com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547) Thread[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0,5,main] java.net.SocketInputStream.socketRead0(Native Method) java.net.SocketInputStream.read(Unknown Source) oracle.net.ns.Packet.receive(Unknown Source) oracle.net.ns.NSProtocol.connect(Unknown Source) oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:858) oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:268) oracle.jdbc.driver.PhysicalConnection.&lt;init&gt;(PhysicalConnection.java:441) oracle.jdbc.driver.T4CConnection.&lt;init&gt;(T4CConnection.java:165) oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35) oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:801) com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:134) com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:182) com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:171) 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) Thread[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2,5,main] java.lang.Thread.sleep(Native Method) com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1805) com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547) 2011-11-04 16:00:25,511 WARN com.mchange.v2.async.ThreadPoolAsynchronousRunner - Task com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@134c6be (in deadlocked PoolThread) failed to complete in maximum time 60000ms. Trying interrupt(). 2011-11-04 16:00:25,511 WARN com.mchange.v2.async.ThreadPoolAsynchronousRunner - Task com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@1da208c (in deadlocked PoolThread) failed to complete in maximum time 60000ms. Trying interrupt(). 2011-11-04 16:00:30,457 WARN com.mchange.v2.resourcepool.BasicResourcePool - com.mchange.v2.resourcepool.BasicResourcePool@24e11c -- Thread unexpectedly interrupted while performing an acquisition attempt. java.lang.InterruptedException: sleep interrupted at java.lang.Thread.sleep(Native Method) at com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1805) at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547) 2011-11-04 16:00:31,502 WARN com.mchange.v2.resourcepool.BasicResourcePool - com.mchange.v2.resourcepool.BasicResourcePool@24e11c -- Thread unexpectedly interrupted while performing an acquisition attempt. java.lang.InterruptedException: sleep interrupted at java.lang.Thread.sleep(Native Method) at com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1805) at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547) 2011-11-04 16:04:19,247 WARN com.mchange.v2.resourcepool.BasicResourcePool - com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@93c4bb -- 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.sql.SQLException: Listener refused the connection with the following error: ORA-12500, TNS:listener failed to start a dedicated server process The Connection descriptor used by the client was: at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112) at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:261) at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:387) at oracle.jdbc.driver.PhysicalConnection.&lt;init&gt;(PhysicalConnection.java:441) at oracle.jdbc.driver.T4CConnection.&lt;init&gt;(T4CConnection.java:165) at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35) at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:801) at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:134) at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:182) at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:171) at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:137) at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1014) at com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:32) at com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1810) at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547) 2011-11-04 16:04:19,247 ERROR com.mchange.v2.resourcepool.BasicResourcePool - A RESOURCE POOL IS PERMANENTLY BROKEN! [com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@93c4bb] 2011-11-04 16:04:19,247 ERROR com.mchange.v2.resourcepool.BasicResourcePool - com.mchange.v2.resourcepool.BasicResourcePool@24e11c -- Unexpectedly broken!!! com.mchange.v2.resourcepool.ResourcePoolException: Unexpected Break Stack Trace! at com.mchange.v2.resourcepool.BasicResourcePool.unexpectedBreak(BasicResourcePool.java:866) at com.mchange.v2.resourcepool.BasicResourcePool.access$1100(BasicResourcePool.java:32) at com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1854) at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547) 2011-11-04 16:04:55,595 WARN com.mchange.v2.resourcepool.BasicResourcePool - com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@1e465c2 -- 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.sql.SQLException: Listener refused the connection with the following error: ORA-12500, TNS:listener failed to start a dedicated server process The Connection descriptor used by the client was: at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112) at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:261) at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:387) at oracle.jdbc.driver.PhysicalConnection.&lt;init&gt;(PhysicalConnection.java:441) at oracle.jdbc.driver.T4CConnection.&lt;init&gt;(T4CConnection.java:165) at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35) at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:801) at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:134) at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:182) at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:171) at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:137) at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1014) at com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:32) at com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1810) at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547) 2011-11-04 16:04:55,595 ERROR com.mchange.v2.resourcepool.BasicResourcePool - A RESOURCE POOL IS PERMANENTLY BROKEN! [com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@1e465c2] 2011-11-04 16:04:55,595 ERROR com.mchange.v2.resourcepool.BasicResourcePool - com.mchange.v2.resourcepool.BasicResourcePool@24e11c -- Unexpectedly broken!!! com.mchange.v2.resourcepool.ResourcePoolException: Unexpected Break Stack Trace!</pre>   <p> </p>

c3p0连接池中获取的Connection对象的close()方法是真的把连接给关闭了?

自己做写了一个管理数据源的DBManager,构想中从数据源里面获取的Connection使用完之后执行close()方法,然后把Connection对象闲置回连接池中。 但是测试出来的结果好像每次执行close()之后connection就销毁了。 代码如下: DBManager.java -------------- package ben.DBUtils; import java.sql.Connection; import java.sql.DatabaseMetaData; import java.sql.SQLException; import java.util.HashMap; import java.util.HashSet; import java.util.Properties; import java.util.Set; import com.mchange.v2.c3p0.ComboPooledDataSource; import org.apache.log4j.Logger; /** * Created with IntelliJ IDEA. * User: Ben * Date: 13-7-3 * Time: 下午5:06 * To change this template use File | Settings | File Templates. */ public class DBManager { //保存数据库连接池的容器 private static HashMap<String, ComboPooledDataSource> datasourceMap = new HashMap<String, ComboPooledDataSource>(); private final static ThreadLocal<Connection> conns = new ThreadLocal<Connection>(); private static Logger logger = Logger.getLogger(DBManager.class); static { InitDataSource(null); } /** * 初始化连接池 * */ private final static void InitDataSource(Properties dbProperties){ try{ if (dbProperties == null){ dbProperties = new Properties(); dbProperties.load(DBManager.class.getClassLoader().getResourceAsStream("dbInfo.properties")); } //获取数据源名称 Set<String> keys = new HashSet<String>(); for (Object key : dbProperties.keySet()){ String skey = (String)key; Integer point = skey.indexOf("."); keys.add(skey.substring(0, point)); } //实例化DataSource并放入容器中 for (String key : keys) { ComboPooledDataSource ds = new ComboPooledDataSource(); ds.setDriverClass(dbProperties.getProperty(key + "." + "Driver")); ds.setJdbcUrl(dbProperties.getProperty(key + "." + "Url")); ds.setUser(dbProperties.getProperty(key + "." + "User")); ds.setPassword(dbProperties.getProperty(key + "." + "Password")); ds.setMaxPoolSize(Integer.parseInt(dbProperties.getProperty(key + "." + "MaxPoolSize"))); ds.setMinPoolSize(Integer.parseInt(dbProperties.getProperty(key + "." + "MinPoolSize"))); ds.setMaxIdleTime(Integer.parseInt(dbProperties.getProperty(key + "." + "MaxIdleTime"))); ds.setInitialPoolSize(Integer.parseInt(dbProperties.getProperty(key + "." + "InitialPoolSize"))); ds.setAcquireIncrement(Integer.parseInt(dbProperties.getProperty(key + "." + "AcquireIncrement"))); ds.setAcquireRetryAttempts(Integer.parseInt(dbProperties.getProperty(key + "." + "AcquireRetryAttempts"))); ds.setAcquireRetryDelay(Integer.parseInt(dbProperties.getProperty(key + "." + "AcquireRetryDelay"))); ds.setMaxStatements(Integer.parseInt(dbProperties.getProperty(key + "." + "MaxStatements"))); ds.setIdleConnectionTestPeriod(Integer.parseInt(dbProperties.getProperty(key + "." + "IdleConnectionTestPeriod"))); ds.setCheckoutTimeout(Integer.parseInt(dbProperties.getProperty(key + "." + "CheckoutTimeout"))); ds.setTestConnectionOnCheckin(Boolean.parseBoolean(dbProperties.getProperty(key + "." + "TestConnectionOnCheckin"))); ds.setTestConnectionOnCheckout(Boolean.parseBoolean(dbProperties.getProperty(key + "." + "TestConnectionOnCheckout"))); datasourceMap.put(key, ds); Connection conn = getConnection(key); DatabaseMetaData metaData = conn.getMetaData(); logger.info("Using DataSource: " + conn.getClass().getName()); closeConnection(); } } catch (Exception e){ logger.error("DataSource Error:" + e.toString()); } } /** * 断开连接池 * */ public final static void closeDataSource(String dataSourceName){ try{ ComboPooledDataSource dataSource = datasourceMap.get(dataSourceName); dataSource.close(); } catch (Exception e){ logger.error("Unable to destroy DataSource! " + e.toString()); } } /** * 获取连接 * @return Connection * */ public final static Connection getConnection(String dataSourceName) throws SQLException{ Connection conn = conns.get(); if (conn == null || conn.isClosed()){ ComboPooledDataSource dataSource = datasourceMap.get(dataSourceName); conn = dataSource.getConnection(); conns.set(conn); } return conn; } /** * 关闭连接 * */ public final static void closeConnection(){ Connection conn = conns.get(); try{ if (conn != null && !conn.isClosed()){ conn.setAutoCommit(true); conn.close(); } } catch (SQLException ex){ logger.error("Unable to close connection! " + ex.toString()); } finally { conns.remove(); //conns.set(null); } } } ---------- dbInfo.properties ----------------- DemoData.AcquireIncrement = 2 DemoData.AcquireRetryAttempts = 30 DemoData.AcquireRetryDelay = 1000 DemoData.CheckoutTimeout = 3000 DemoData.Driver = com.microsoft.sqlserver.jdbc.SQLServerDriver DemoData.IdleConnectionTestPeriod = 18000 DemoData.InitialPoolSize = 2 DemoData.MaxIdleTime = 300 DemoData.MaxPoolSize = 100 DemoData.MaxStatements = 1000 DemoData.MinPoolSize = 2 DemoData.Password = 123 DemoData.TestConnectionOnCheckin = false DemoData.TestConnectionOnCheckout = false DemoData.Url = jdbc:sqlserver://localhost:1433;DatabaseName=DemoData DemoData.User = sa ---------- 测试代码:TestDBManager.java ----------------------- package ben.DBUtils; import java.sql.Connection; /** * Created with IntelliJ IDEA. * User: Ben * Date: 13-7-6 * Time: 上午12:28 * To change this template use File | Settings | File Templates. */ public class TestDBManager { public static void main(String[] args) { for (Integer i=0; i<10; i++){ try{ System.out.println(DBManager.getConnection("DemoData")); DBManager.closeConnection(); System.out.println("---------------------------"); } catch (Exception ex){ ex.printStackTrace(); } } } } 打印出来的结果每次都不一样 com.mchange.v2.c3p0.impl.NewProxyConnection@ff5c225 --------------------------- com.mchange.v2.c3p0.impl.NewProxyConnection@5bafcc2c --------------------------- com.mchange.v2.c3p0.impl.NewProxyConnection@ded0b93 --------------------------- com.mchange.v2.c3p0.impl.NewProxyConnection@25057fe --------------------------- com.mchange.v2.c3p0.impl.NewProxyConnection@198ad24a --------------------------- com.mchange.v2.c3p0.impl.NewProxyConnection@1228bd68 --------------------------- com.mchange.v2.c3p0.impl.NewProxyConnection@36db09fa --------------------------- com.mchange.v2.c3p0.impl.NewProxyConnection@35886ba1 --------------------------- com.mchange.v2.c3p0.impl.NewProxyConnection@17d8986 --------------------------- com.mchange.v2.c3p0.impl.NewProxyConnection@2bb9e538 ---------------------------

使用C3P0出现错误…NullPointerException…

![图片说明](https://img-ask.csdn.net/upload/201605/03/1462273145_921637.png) 测试的是fun1()方法 ``` public void fun1(){ User user = new User(4, "cyoeki2", "123", "xzs"); addUser(user); } public void addUser(User user){ QR qr = new QR(JdbcUtils.getDataSource()); String sql = "insert into users values(?,?,?,?)"; Object[] params ={user.getId(),user.getUsername(),user.getPassword(),user.getNickname()}; qr.update(sql, params); } public class QR<T> { private DataSource dataSource; public QR() { super(); } public QR(DataSource dataSource) { super(); this.dataSource = dataSource; } public int update(String sql, Object...params){ Connection con = null; PreparedStatement pstmt = null; try { con=dataSource.getConnection(); pstmt = con.prepareStatement(sql); initParams(pstmt,params); return pstmt.executeUpdate(); } catch (Exception e) { throw new RuntimeException(e); }finally{ try{ if(pstmt!=null)pstmt.close(); if(con!=null)con.close();; }catch(SQLException e){ throw new RuntimeException(e); } } } private void initParams(PreparedStatement pstmt,Object...params) throws SQLException{ for(int i=0;i<params.length;i++){ pstmt.setObject(i+1, params[i]); } } public T query(String sql,RsHandler rs,Object...params){ return null; } } interface RsHandler<T>{ public T handle(ResultSet rs); } public class JdbcUtils { private static ComboPooledDataSource dataSorce = new ComboPooledDataSource(); public static Connection getConnection() throws SQLException{ return dataSorce.getConnection(); } public static DataSource getDataSource(){ return dataSorce; } } ```

C3P0链接池关闭错误导致的线程问题如何解决

ssh框架下使用c3p0连接池启动tomcat服务器报出如下错误:The web application [RupengElec] appears to have started a thread named [MySQL Statement Cancellation Timer] but has failed to stop it. This is very likely to create a memory leak. 请问这个错误是什么引起的,如何解决? ``` <!-- c3p0数据库连接池配置 --> <bean name="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"> <property name="jdbcUrl" value="jdbc:mysql://localhost:3306/ElecProject?useUnicode=true&amp;characterEncoding=utf8"></property> <property name="driverClass" value="com.mysql.jdbc.Driver"></property> <property name="user" value="root"></property> <property name="password" value="root"></property> <property name="initialPoolSize" value="5"></property> <property name="maxPoolSize" value="30"></property> <property name="minPoolSize" value="3"></property> </bean> ```

在中国程序员是青春饭吗?

今年,我也32了 ,为了不给大家误导,咨询了猎头、圈内好友,以及年过35岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...

程序员请照顾好自己,周末病魔差点一套带走我。

程序员在一个周末的时间,得了重病,差点当场去世,还好及时挽救回来了。

C++(数据结构与算法)78:---分而治之

一、分而治之的思想 分而治之方法与软件设计的模块化方法非常相似 分而治之通常不用于解决问题的小实例,而要解决一个问题的大实例。一般步骤为: ①把一个大实例分为两个或多个更小的实例 ②分别解决每个小实例 ③把这些小实例的解组合成原始大实例的解 二、实际应用之找出假币 问题描述 一个袋子有16个硬币,其中只有一个是假币,这个假币比其他的真币重量轻(其他所有真币的重量都是相同的)...

springboot+jwt实现token登陆权限认证

一 前言 此篇文章的内容也是学习不久,终于到周末有时间码一篇文章分享知识追寻者的粉丝们,学完本篇文章,读者将对token类的登陆认证流程有个全面的了解,可以动态搭建自己的登陆认证过程;对小项目而已是个轻量级的认证机制,符合开发需求;更多精彩原创内容关注公主号知识追寻者,读者的肯定,就是对作者的创作的最大支持; 二 jwt实现登陆认证流程 用户使用账号和面发出post请求 服务器接受到请求后使用私...

技术大佬:我去,你写的 switch 语句也太老土了吧

昨天早上通过远程的方式 review 了两名新来同事的代码,大部分代码都写得很漂亮,严谨的同时注释也很到位,这令我非常满意。但当我看到他们当中有一个人写的 switch 语句时,还是忍不住破口大骂:“我擦,小王,你丫写的 switch 语句也太老土了吧!” 来看看小王写的代码吧,看完不要骂我装逼啊。 private static String createPlayer(PlayerTypes p...

win10暴力查看wifi密码

刚才邻居打了个电话说:喂小灰,你家wifi的密码是多少,我怎么连不上了。 我。。。 我也忘了哎,就找到了一个好办法,分享给大家: 第一种情况:已经连接上的wifi,怎么知道密码? 打开:控制面板\网络和 Internet\网络连接 然后右击wifi连接的无线网卡,选择状态 然后像下图一样: 第二种情况:前提是我不知道啊,但是我以前知道密码。 此时可以利用dos命令了 1、利用netsh wlan...

女程序员,为什么比男程序员少???

昨天看到一档综艺节目,讨论了两个话题:(1)中国学生的数学成绩,平均下来看,会比国外好?为什么?(2)男生的数学成绩,平均下来看,会比女生好?为什么?同时,我又联想到了一个技术圈经常讨...

副业收入是我做程序媛的3倍,工作外的B面人生是怎样的?

提到“程序员”,多数人脑海里首先想到的大约是:为人木讷、薪水超高、工作枯燥…… 然而,当离开工作岗位,撕去层层标签,脱下“程序员”这身外套,有的人生动又有趣,马上展现出了完全不同的A/B面人生! 不论是简单的爱好,还是正经的副业,他们都干得同样出色。偶尔,还能和程序员的特质结合,产生奇妙的“化学反应”。 @Charlotte:平日素颜示人,周末美妆博主 大家都以为程序媛也个个不修边幅,但我们也许...

MySQL数据库面试题(2020最新版)

文章目录数据库基础知识为什么要使用数据库什么是SQL?什么是MySQL?数据库三大范式是什么mysql有关权限的表都有哪几个MySQL的binlog有有几种录入格式?分别有什么区别?数据类型mysql有哪些数据类型引擎MySQL存储引擎MyISAM与InnoDB区别MyISAM索引与InnoDB索引的区别?InnoDB引擎的4大特性存储引擎选择索引什么是索引?索引有哪些优缺点?索引使用场景(重点)...

如果你是老板,你会不会踢了这样的员工?

有个好朋友ZS,是技术总监,昨天问我:“有一个老下属,跟了我很多年,做事勤勤恳恳,主动性也很好。但随着公司的发展,他的进步速度,跟不上团队的步伐了,有点...

我入职阿里后,才知道原来简历这么写

私下里,有不少读者问我:“二哥,如何才能写出一份专业的技术简历呢?我总感觉自己写的简历太烂了,所以投了无数份,都石沉大海了。”说实话,我自己好多年没有写过简历了,但我认识的一个同行,他在阿里,给我说了一些他当年写简历的方法论,我感觉太牛逼了,实在是忍不住,就分享了出来,希望能够帮助到你。 01、简历的本质 作为简历的撰写者,你必须要搞清楚一点,简历的本质是什么,它就是为了来销售你的价值主张的。往深...

程序员写出这样的代码,能不挨骂吗?

当你换槽填坑时,面对一个新的环境。能够快速熟练,上手实现业务需求是关键。但是,哪些因素会影响你快速上手呢?是原有代码写的不够好?还是注释写的不够好?昨夜...

带了6个月的徒弟当了面试官,而身为高级工程师的我天天修Bug......

即将毕业的应届毕业生一枚,现在只拿到了两家offer,但最近听到一些消息,其中一个offer,我这个组据说客户很少,很有可能整组被裁掉。 想问大家: 如果我刚入职这个组就被裁了怎么办呢? 大家都是什么时候知道自己要被裁了的? 面试软技能指导: BQ/Project/Resume 试听内容: 除了刷题,还有哪些技能是拿到offer不可或缺的要素 如何提升面试软实力:简历, 行为面试,沟通能...

优雅的替换if-else语句

场景 日常开发,if-else语句写的不少吧??当逻辑分支非常多的时候,if-else套了一层又一层,虽然业务功能倒是实现了,但是看起来是真的很不优雅,尤其是对于我这种有强迫症的程序"猿",看到这么多if-else,脑袋瓜子就嗡嗡的,总想着解锁新姿势:干掉过多的if-else!!!本文将介绍三板斧手段: 优先判断条件,条件不满足的,逻辑及时中断返回; 采用策略模式+工厂模式; 结合注解,锦...

!大部分程序员只会写3年代码

如果世界上都是这种不思进取的软件公司,那别说大部分程序员只会写 3 年代码,恐怕就没有程序员这种职业。

离职半年了,老东家又发 offer,回不回?

有小伙伴问松哥这个问题,他在上海某公司,在离职了几个月后,前公司的领导联系到他,希望他能够返聘回去,他很纠结要不要回去? 俗话说好马不吃回头草,但是这个小伙伴既然感到纠结了,我觉得至少说明了两个问题:1.曾经的公司还不错;2.现在的日子也不是很如意。否则应该就不会纠结了。 老实说,松哥之前也有过类似的经历,今天就来和小伙伴们聊聊回头草到底吃不吃。 首先一个基本观点,就是离职了也没必要和老东家弄的苦...

2020阿里全球数学大赛:3万名高手、4道题、2天2夜未交卷

阿里巴巴全球数学竞赛( Alibaba Global Mathematics Competition)由马云发起,由中国科学技术协会、阿里巴巴基金会、阿里巴巴达摩院共同举办。大赛不设报名门槛,全世界爱好数学的人都可参与,不论是否出身数学专业、是否投身数学研究。 2020年阿里巴巴达摩院邀请北京大学、剑桥大学、浙江大学等高校的顶尖数学教师组建了出题组。中科院院士、美国艺术与科学院院士、北京国际数学...

为什么你不想学习?只想玩?人是如何一步一步废掉的

不知道是不是只有我这样子,还是你们也有过类似的经历。 上学的时候总有很多光辉历史,学年名列前茅,或者单科目大佬,但是虽然慢慢地长大了,你开始懈怠了,开始废掉了。。。 什么?你说不知道具体的情况是怎么样的? 我来告诉你: 你常常潜意识里或者心理觉得,自己真正的生活或者奋斗还没有开始。总是幻想着自己还拥有大把时间,还有无限的可能,自己还能逆风翻盘,只不是自己还没开始罢了,自己以后肯定会变得特别厉害...

男生更看重女生的身材脸蛋,还是思想?

往往,我们看不进去大段大段的逻辑。深刻的哲理,往往短而精悍,一阵见血。问:产品经理挺漂亮的,有点心动,但不知道合不合得来。男生更看重女生的身材脸蛋,还是...

为什么程序员做外包会被瞧不起?

二哥,有个事想询问下您的意见,您觉得应届生值得去外包吗?公司虽然挺大的,中xx,但待遇感觉挺低,马上要报到,挺纠结的。

当HR压你价,说你只值7K,你该怎么回答?

当HR压你价,说你只值7K时,你可以流畅地回答,记住,是流畅,不能犹豫。 礼貌地说:“7K是吗?了解了。嗯~其实我对贵司的面试官印象很好。只不过,现在我的手头上已经有一份11K的offer。来面试,主要也是自己对贵司挺有兴趣的,所以过来看看……”(未完) 这段话主要是陪HR互诈的同时,从公司兴趣,公司职员印象上,都给予对方正面的肯定,既能提升HR的好感度,又能让谈判气氛融洽,为后面的发挥留足空间。...

面试:第十六章:Java中级开发

HashMap底层实现原理,红黑树,B+树,B树的结构原理 Spring的AOP和IOC是什么?它们常见的使用场景有哪些?Spring事务,事务的属性,传播行为,数据库隔离级别 Spring和SpringMVC,MyBatis以及SpringBoot的注解分别有哪些?SpringMVC的工作原理,SpringBoot框架的优点,MyBatis框架的优点 SpringCould组件有哪些,他们...

早上躺尸,晚上干活:硅谷科技公司这么流行迟到?

硅谷科技公司上班时间OPEN早已不是什么新鲜事,早九晚五是常态,但有很多企业由于不打卡,员工们10点、11点才“姗姗来迟”的情况也屡见不鲜。 这种灵活的考勤制度为人羡慕,甚至近年来,国内某些互联网企业也纷纷效仿。不过,硅谷普遍弹性的上班制度是怎么由来的呢?这种“流行性迟到”真的有那么轻松、悠哉吗? 《动态规划专题班》 课程试听内容: 动态规划的解题要领 动态规划三大类 求最值/计数/可行性 常...

面试阿里p7,被按在地上摩擦,鬼知道我经历了什么?

面试阿里p7被问到的问题(当时我只知道第一个):@Conditional是做什么的?@Conditional多个条件是什么逻辑关系?条件判断在什么时候执...

Python爬虫,高清美图我全都要(彼岸桌面壁纸)

爬取彼岸桌面网站较为简单,用到了requests、lxml、Beautiful Soup4

无代码时代来临,程序员如何保住饭碗?

编程语言层出不穷,从最初的机器语言到如今2500种以上的高级语言,程序员们大呼“学到头秃”。程序员一边面临编程语言不断推陈出新,一边面临由于许多代码已存在,程序员编写新应用程序时存在重复“搬砖”的现象。 无代码/低代码编程应运而生。无代码/低代码是一种创建应用的方法,它可以让开发者使用最少的编码知识来快速开发应用程序。开发者通过图形界面中,可视化建模来组装和配置应用程序。这样一来,开发者直...

面试了一个 31 岁程序员,让我有所触动,30岁以上的程序员该何去何从?

最近面试了一个31岁8年经验的程序猿,让我有点感慨,大龄程序猿该何去何从。

大三实习生,字节跳动面经分享,已拿Offer

说实话,自己的算法,我一个不会,太难了吧

程序员垃圾简历长什么样?

已经连续五年参加大厂校招、社招的技术面试工作,简历看的不下于万份 这篇文章会用实例告诉你,什么是差的程序员简历! 疫情快要结束了,各个公司也都开始春招了,作为即将红遍大江南北的新晋UP主,那当然要为小伙伴们做点事(手动狗头)。 就在公众号里公开征简历,义务帮大家看,并一一点评。《启舰:春招在即,义务帮大家看看简历吧》 一石激起千层浪,三天收到两百多封简历。 花光了两个星期的所有空闲时...

Java岗开发3年,公司临时抽查算法,离职后这几题我记一辈子

前几天我们公司做了一件蠢事,非常非常愚蠢的事情。我原以为从学校出来之后,除了找工作有测试外,不会有任何与考试有关的事儿。 但是,天有不测风云,公司技术总监、人事总监两位大佬突然降临到我们事业线,叫上我老大,给我们组织了一场别开生面的“考试”。 那是一个风和日丽的下午,我翘着二郎腿,左手端着一杯卡布奇诺,右手抓着我的罗技鼠标,滚动着轮轴,穿梭在头条热点之间。 “淡黄的长裙~蓬松的头发...

立即提问
相关内容推荐