Java program and mySQL connectivity issue: No suitable driver found

后端 未结 4 1428
忘掉有多难
忘掉有多难 2021-01-23 04:01

I\'ve been having a problem with mySQL database connectivity. I\'m getting an error:

No suitable driver found for jdbc:mysql://127.0.0.1/sakila.

4条回答
  •  南笙
    南笙 (楼主)
    2021-01-23 04:34

    You need to instantiate the driver before calling the getConnection :

    String pdriver = "com.mysql.jdbc.Driver";
    Class.forName(pdriver).newInstance();
    

提交回复
热议问题