Exception in thread "main" java.sql.SQLException: Connections could not be acquired from the underly




2015-01-10 16:00
	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 lee.BeanTest.main(BeanTest.java:26)
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)
	... 2 more-------------------
代码
	public static void main(String[] args)throws Exception
	{
		ApplicationContext ctx = new
			ClassPathXmlApplicationContext("bean.xml");
		DataSource ds = (DataSource)ctx.getBean("dataSource");
		Connection conn = ds.getConnection();
		PreparedStatement pstmt = conn.prepareStatement(
			"insert into news_inf value(null , ? , ?)");
		pstmt.setString(1 , "XXXX");
		pstmt.setString(2 , "YYYY");
		pstmt.executeUpdate();
		pstmt.close();
		conn.close();
	}
bean。xml就不发出来了,上面与c3p0数据源的配置 是OK的  ------------------------------应该是连接mysql的密码出错了

java报错是怎么回事,我只想连下数据库而已

2015-01-10 16:00 白羊luojishu  |  分类:数据库DB  |  浏览15次
Exception in thread "main" 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 lee.BeanTest.main(BeanTest.java:26)
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)
	... 2 more-------------------
代码
	public static void main(String[] args)throws Exception
	{
		ApplicationContext ctx = new
			ClassPathXmlApplicationContext("bean.xml");
		DataSource ds = (DataSource)ctx.getBean("dataSource");
		Connection conn = ds.getConnection();
		PreparedStatement pstmt = conn.prepareStatement(
			"insert into news_inf value(null , ? , ?)");
		pstmt.setString(1 , "疯狂Java讲义");
		pstmt.setString(2 , "Struts 2权威指南");
		pstmt.executeUpdate();
		pstmt.close();
		conn.close();
	}
bean。xml就不发出来了,上面与c3p0数据源的配置 是OK的

你可能感兴趣的:(Exception in thread "main" java.sql.SQLException: Connections could not be acquired from the underly)