简体   繁体   English

org.postgresql.util.PSQLException:致命:数据库“&lt;<database_name> &gt;” 不存在,在 AWS java lambda</database_name>

[英]org.postgresql.util.PSQLException: FATAL: database “<<database_name>>” does not exist, in the AWS java lambda

I am facing the error, org.postgresql.util.PSQLException: FATAL: database "" does not exist我面临错误,org.postgresql.util.PSQLException: FATAL: database "" does not exist

Java code is deployed in AWS lambda to get connect the postgres database running in RDS. Java 代码部署在 AWS lambda 中,以连接在 RDS 中运行的 postgres 数据库。

Code代码

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();
}

Strange as it sounds, that would indicated that there is no database called postgres in that database cluster.听起来很奇怪,这表明该数据库集群中没有名为postgres的数据库。

Replace the last part of your JDBC URL with an existing database.用现有数据库替换 JDBC URL 的最后一部分。

You should check that your Lambda function is configured to be connected to the same VPC of your RDS instance.您应该检查您的 Lambda function 是否配置为连接到您的 RDS 实例的同一 VPC。 Otherwise, they will not be able to communicate.否则,他们将无法交流。

The official documentation provides more details as well as some tutorials/examples.官方文档提供了更多详细信息以及一些教程/示例。 You can also configure it manually in the AWS Lambda console (in the Configuration pane, under Network, near the bottom of the page).您还可以在 AWS Lambda 控制台中手动配置它(在配置窗格中,在靠近页面底部的网络下)。 Finally, AWS has a knowledge base entry on how do I connect a Lambda function to a dedicated VPC?最后,AWS 有一个关于如何将 Lambda function 连接到专用 VPC 的知识库条目?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 org.postgresql.util.PSQLException:致命:数据库“ postgres&gt;”不存在 - org.postgresql.util.PSQLException: FATAL: database “postgres>” does not exist org.postgresql.util.PSQLException:致命:数据库“pma-springbootdb” - org.postgresql.util.PSQLException: FATAL: database “pma-springbootdb” 引起:org.postgresql.util.PSQLException:尝试自动创建数据库时数据库不存在 - Caused by: org.postgresql.util.PSQLException: database doesn't exist when trying to auto-create database org.postgresql.util.PSQLException:错误:关系“序列”不存在 - org.postgresql.util.PSQLException: ERROR: relation “sequence” does not exist org.postgresql.util.PSQLException:错误:关系“产品”不存在 - org.postgresql.util.PSQLException: ERROR: relation "products" does not exist Java EE:org.postgresql.util.PSQLException:列不存在,但存在 - Java EE: org.postgresql.util.PSQLException: Column does not exist, while it does exists org.postgresql.util.PSQLException:错误:关系“table_name”不存在 - org.postgresql.util.PSQLException:ERROR: relation "table_name" does not exist org.postgresql.util.PSQLException:错误:列“id”不存在 - Java Web 服务 - org.postgresql.util.PSQLException: ERROR: column "id" does not exist - Java Web Service org.postgresql.util.PSQLException:错误:列 systementi0_.id 不存在 - Hibernate、PostgreSql - org.postgresql.util.PSQLException: Error: column systementi0_.id does not exist - Hibernate, PostgreSql org.postgresql.util.PSQLException:错误:关系“用户”不存在 - SpringBoot,Hibernate,Postgresql - org.postgresql.util.PSQLException: ERROR: relation "users" does not exist - SpringBoot, Hibernate, Postgresql
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM