【发布时间】:2020-11-21 01:48:47
【问题描述】:
在 Java 15 中,使用来自 jdbc.postgresql.org 的 PostgreSQL JDBC 驱动程序(版本 42.2.18,JDBC4.2)和 DataSource:
PGSimpleDataSource ds = new PGSimpleDataSource();
ds.setServerNames( new String[] { "my-server-address" } );
ds.setPortNumbers( new int[] { 25060 } );
ds.setSsl( true );
ds.setDatabaseName( "mydb" );
ds.setUser( "scott" );
ds.setPassword( "tiger" );
this.dataSource = ds;
…代码Connection conn = this.dataSource.getConnection(); 抛出此异常:
org.postgresql.util.PSQLException:无法打开 SSL 根证书文件 /Users/basilbourque/.postgresql/root.crt。
我知道我的 Postgres 12 服务器是为 SSL 连接设置的,因为我的 IntelliJ Ultimate 有一个数据库访问功能 (DataGrip) 可以通过 SSL (TLS) 保护成功连接。
那么我在 JDBC 中的 DataSource 配置有什么问题?
【问题讨论】:
标签: postgresql ssl jdbc datasource