1、准备两个库,导入lib中
mchange-commons 以及c3p0
2、编写测试代码
ComboPooledDataSource cpds = new ComboPooledDataSource();
try {
cpds.setDriverClass( "org.postgresql.Driver" ); //loads the jdbc driver
} catch (PropertyVetoException e) {
e.printStackTrace();
}
cpds.setJdbcUrl( "jdbc:postgresql://127.0.0.1:5432/postgres" );
cpds.setUser("postgres");
cpds.setPassword("123456");
Connection connection= null;
try {
connection = cpds.getConnection();
System.out.println("1231231");
System.out.println("链接信息"+connection);
} catch (SQLException e) {
e.printStackTrace();
}
3、测试结果