我已经可以用windows命令行成功连接远端Amazon EC2 MySQL server,并且设置完数据
库和表格。
接下来要解决怎么在装上Amazon AWS插件的Eclipse IDE开发的JAVA代码中配置连接这
个MySQL数据库。
按照AWS官方教程 http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_de
Establish a database connection in your code using your Amazon RDS DB
Instance's connectivity information. You can access your connectivity
information using environment variables. The following shows how you would
connect to the database on an RDS instance.
String dbName = System.getProperty("RDS_DB_NAME");
String userName = System.getProperty("RDS_USERNAME");
String password = System.getProperty("RDS_PASSWORD");
String hostname = System.getProperty("RDS_HOSTNAME");
String port = System.getProperty("RDS_PORT");
Build your JDBC connection string:
String jdbcUrl = "jdbc:mysql://" + hostname + ":" + port + "/" + dbName + "?
user=" + userName + "&password=" + password;
用以上方法不需要输入自己的数据名称、用户名、密码和端口。
但我怎么也连接不上啊。
直接用下面的URL也连接不上
jdbc:mysql://mydbinstance.abcdefghijkl.us-east-1.rds.amazonaws.com:3306/
employees?user=sa&password=mypassword
跪求大牛指教!谢谢