简体   繁体   English

无法在 AWS 中使用 JDBC 访问 RDS

[英]Unable to Access RDS with JDBC in AWS

I am finding hard time connecting to RDS using JDBC connection, I am able to connect through MYSQL workbench, I deployed my WAR file in A WSwhich is running tomcat, this WAR file has my JDBCcode connecting to RDS, but I am not even able to establish connection.我发现很难使用 JDBC 连接连接到 RDS,我能够通过 MYSQL 工作台连接,我将我的 WAR 文件部署在运行 tomcat 的 WS 中,这个 WAR 文件有我的 JDBCcode 连接到 RDS,但我什至无法建立连接。 My code is as below:-我的代码如下: -

public static Connection getconnection(){

     String connectionUrl = "jdbc:mysql://testinstance.cj3ixhryi3fb.us-west-2.rds.amazonaws.com:3306/testDB";
        String dbUser = "testuser";
        String dbPwd = "usertest";
        Connection conn = null;

        try {
            conn = (Connection) DriverManager.getConnection(connectionUrl, dbUser, dbPwd);
            System.out.println("conn Available");
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            System.out.println("fetch otion error"+e.getLocalizedMessage());
        }

        return conn;
}   

I included all the necessary jar files, and rules security groups but no luck.我包含了所有必要的 jar 文件和规则安全组,但没有运气。

I am using the EC2 security group for RDS.我正在为 RDS 使用 EC2 安全组。 Does RDS will use ec2 security groups? RDS 会使用 ec2 安全组吗? or I need to have different security group for RDS?或者我需要为 RDS 设置不同的安全组?

the testinstance is a working link if any one wanna test.如果有人想测试,testinstance 是一个工作链接。

It could be that your instance is in a VPC and your RDS instance isn't set up in a VPC subnet group.可能是您的实例位于 VPC 中,而您的 RDS 实例未设置在 VPC 子网组中。

If you want to connect to an RDS instance from a server instance in a VPC, your RDS instance has to be deployed in a VPC subnet.如果您想从 VPC 中的服务器实例连接到 RDS 实例,您的 RDS 实例必须部署在 VPC 子网中。

http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_VPC.CreateDBSubnetGroup.html http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_VPC.CreateDBSubnetGroup.html

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

相关问题 使用 JDBC 连接到 AWS RDS 实例 - Connecting to AWS RDS Instance with JDBC 使用 IAM 身份验证和 Spring JDBC(DataSource 和 JdbcTemplace)访问 AWS RDS - Accessing AWS RDS using IAM Authentication and Spring JDBC (DataSource and JdbcTemplace) 使用带有 Node.js 的 aws-secretsmanager-jdbc 连接到 RDS? - Connecting to RDS using aws-secretsmanager-jdbc with Node.js? 使用 AWS Secrets Manager 管理 RDS 访问 - Manage RDS access with AWS Secrets Manager 无法使用Eclipse访问Amazon RDS - Unable to access Amazon RDS using Eclipse AWS RDS连接数据库错误:com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:通信链接失败 - AWS RDS connection database error : com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure 无法从AWS Lambda连接到AWS RDS MySql DB。 ClassNotFoundException:com.mysql.jdbc - Not able to connect to AWS RDS MySql DB from AWS Lambda. ClassNotFoundException: com.mysql.jdbc 无法从 pgadmin4 连接到 AWS RDS postgres 实例 - unable to connect to AWS RDS postgres instance from pgadmin4 您如何从AWS访问RDS数据库 - How do you access RDS databases from AWS 如何通过 JDBC 连接器从我的本地 java 应用程序连接到 AWS RDS - How to connect to AWS RDS from my local java application by JDBC connector
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM