简体   繁体   中英

JAVA: JDBC Connection by URL Aurora(mysql) aws

i want to connect to a D by an URL i got to make the conections.

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? 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

在连接之前使用以下方法加载驱动程序

    Class.forName("<driver class name>");

I think, you need to do two things here that are:-

1.Load the mysql driver class.

 Class.forName("com.mysql.jdbc.Driver");

2.Change the connection url like this-

 jdbc:mysql://combis.cpgtn4fi7t5t.us-east-1.rds.amazonaws.com/am_myDataBase?useSSL=false

I hope it will work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM