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、测试结果

c3p0链接postgres

相关文章:

  • 2021-04-24
  • 2021-10-18
  • 2022-12-23
猜你喜欢
  • 2021-11-01
  • 2022-12-23
  • 2021-11-03
  • 2021-11-10
  • 2022-12-23
  • 2021-11-06
相关资源
相似解决方案