我的代码存在以下问题:
import java.sql.*;
public class App {
public static void main(String[] args){
String url = "jdbc:mysql://localhost:3306" ;
try{
Class.forName("com.mysql.jdbc.Driver");
}
catch(ClassNotFoundException e)
{ System.out.println("Eroare incarcare driver!\n" + e);
return;
}
try{
Connection con = DriverManager.getConnection(url);
// Golim tabelul persoane
String sql = "DELETE FROM persoane";
Statement stmt = con.createStatement();
stmt.executeUpdate(sql);
stmt.execute("CREATE DATABASE IF NOT EXISTS test");
stmt.execute("USE test");
我遇到了异常(exception)...知道如何才能完成这项工作吗?谢谢。
enter code here
最佳答案
您需要下载 jdbc 连接器并将其添加到类路径中。
关于Java数据库连接问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29077337/