,java,postgresql,amazon-web-services,aws-lambda,amazon-rds"/>

首页 > 解决方案 > org.postgresql.util.PSQLException:致命:数据库“<>" 不存在,在 AWS java lambda 中

问题描述

我面临错误,org.postgresql.util.PSQLException: FATAL: database "" does not exist

Java 代码部署在 AWS lambda 中以连接在 RDS 中运行的 postgres 数据库。

代码

String jdbcUrl = "jdbc:postgresql://database-1.cfgz85wxhk0z.eu-west-1.rds.amazonaws.com:5432/postgres";

Connection connection = null;
try {
    connection = DriverManager.getConnection(jdbcUrl, "database_name", "Password");
    Statement st = connection.createStatement();
    st.execute("select * from <schema>.employee;");
} catch (SQLException e) {
    e.printStackTrace();
} catch(Exception e) {
    e.printStackTrace();
}

标签: javapostgresqlamazon-web-servicesaws-lambdaamazon-rds

解决方案


听起来很奇怪,这表明该postgres数据库集群中没有调用数据库。

将 JDBC URL 的最后一部分替换为现有数据库。


推荐阅读