2
我是新來的服務器和數據庫。我一直試圖測試一個java應用程序,它連接,讀取和修改託管在amazon ec2上的Mysql數據庫。JDBC-Mysql亞馬遜EC2連接
System.out.println("-------- MySQL JDBC Connection Testing ------------");
String DNS = "MYDNS";
String myDBname = "DBNAMe"
String MYSQLUSER = "USER";
String MYSQLPW = "PW";
try {
Class.forName("com.mysql.jdbc.Driver");
} catch (ClassNotFoundException e) {
System.out.println("Where is your MySQL JDBC Driver?");
e.printStackTrace();
return;
}
System.out.println("MySQL JDBC Driver Registered!");
Connection connection = null;
try {
connection = DriverManager.getConnection("jdbc:mysql://" [email protected]"/"+myDBname, MYSQLUSER, MYSQLPASS)
} catch (SQLException e) {
System.out.println("Connection Failed! Check output console");
currentDir = "broke";
}
if (connection != null) {
System.out.println("You made it, take control your database now!");
} else {
System.out.println("Failed to make connection!");
}
的問題是,儘管能夠通過使用MySQL工作臺憑據連接,增加3306到我的安全組,結合0.0.0.0到MySQL的配置,我仍然不能得到持續的連接(這樣做後,一些關於SO的其他類似問題的搜索)
任何人都有什麼洞察力,以什麼可能是錯的?我嘗試了getConnection()參數的很多變體。