[英]JAVA: JDBC Connection by URL Aurora(mysql) aws
i want to connect to a D by an URL i got to make the conections. 我想通过要连接的URL连接到D。
static Connection cnx = null;
public static Connection obtener() throws SQLException{
if (cnx == null) {
try {
cnx = DriverManager.getConnection("jdbc:mysql://combis.cpgtn4fi7t5t.us-east-1.rds.amazonaws.com/am_myDataBase", "user", "pass");
}catch (SQLException es) {
// TODO: handle exception
throw new SQLException(es);
}
}
return cnx;
}
and i can not get the connection. 我无法获得连接。 Is it well written the URL?
URL写得好吗? got this Error:
得到这个错误:
java.sql.SQLException: java.sql.SQLException: No suitable driver found for jdbc:mysql://combis.cpgtn4fi7t5t.us-east-1.rds.amazonaws.com/am_myDataBase java.sql.SQLException:java.sql.SQLException:找不到适用于jdbc的驱动程序:mysql://combis.cpgtn4fi7t5t.us-east-1.rds.amazonaws.com/am_myDataBase
在连接之前使用以下方法加载驱动程序
Class.forName("<driver class name>");
I think, you need to do two things here that are:- 我认为,您需要在这里做两件事:
1.Load the mysql driver class. 1.加载mysql驱动程序类。
Class.forName("com.mysql.jdbc.Driver");
2.Change the connection url like this- 2.像这样更改连接URL-
jdbc:mysql://combis.cpgtn4fi7t5t.us-east-1.rds.amazonaws.com/am_myDataBase?useSSL=false
I hope it will work. 我希望它能起作用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.