我在通过wildfly管理控制台创建数据源连接到PostgreSQL 12时出现异常。
它在我的另一台安装了PostgreSQL 9.5的机器上运行良好。当我在没有数据源的情况下连接时,它似乎工作得很好。
try (Connection conn = DriverManager.getConnection(
"jdbc:postgresql://127.0.0.1:5432/registrar", "postgres", "postgres")) {
if (conn != null) {
System.out.println("Connected to the database!");
Statement statement = conn.createStatement();
ResultSet rs = statement.executeQuery("Select * FROM public.user LIMIT 10");
while(rs.next())
System.out.println(rs.getString(2));
} else {
System.out.println("Failed to make connection!");
}但是当我创建一个像这样的数据源时:

这是当我尝试从UI测试连接时得到的异常。
Request
{
"address" => [
("subsystem" => "datasources"),
("data-source" => "RegistrarDS")
],
"operation" => "test-connection-in-pool"
}
Response
Internal Server Error
{
"outcome" => "failed",
"failure-description" => "WFLYJCA0040: failed to invoke operation: WFLYJCA0047: Connection is not valid",
"rolled-back" => true,
"response-headers" => {"process-state" => "reload-required"}
}PostgreSQL 12有什么变化吗?可能的问题是什么?
发布于 2020-01-10 21:23:23
可能是驱动程序中定义的数据源类存在问题,如issues.redhat.com上的here所述
如果定义了数据源类,则它优先创建数据源,因此它只能使用连接属性。
由于没有一个适用于所有驱动程序的connection-url属性,因此如果要定义数据源类,则必须使用connection-properties。
您可以尝试的另一件事是设置“连接属性”而不是“连接URL”,并确保您使用的是正确的/最新的驱动程序jar文件。
另请查看Postgresql日志,了解有关此异常的更多信息。
https://stackoverflow.com/questions/59682098
复制相似问题