未能配置正确
public class C3P0Demo1 {
public static void main(String[] args) throws SQLException {
1.创建数据库连接池对象
DataSource ds=new ComboPooledDataSource();
2.获取连接对象
Connection conn = ds.getConnection();
3.打印操作,判断对错
System.out.println(conn);
警告: com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@4d6f1626 -- 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: Cannot invoke "String.startsWith(String)" because "url" is null
按照B站视频 需要几个jra包还有xml
能够有输出语句
NullPointerException: Cannot invoke "String.startsWith(String)" because "url" is null
url为空,url配置看下。
dataSource = new ComboPooledDataSource();
dataSource.setUser("root");
dataSource.setPassword("123456");
dataSource.setJdbcUrl("jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=utf-8");
dataSource.setDriverClass("com.mysql.jdbc.Driver");