[英]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 的知识库条目?
https://www.reddit.com/r/aws/comments/a75gfw/database_does_not_exist_when_connecting_to/ Followed some suggestions from the above link. https://www.reddit.com/r/aws/comments/a75gfw/database_does_not_exist_when_connecting_to/遵循上述链接的一些建议。 Issue resolved问题解决了
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.