Java,SQL数据库连接错误

时间:2018-05-27 02:40:24

标签: java mysql mysql-error-1064

我是新手,正在学习使程序连接到mysql数据库,但是有一个错误。我想知道如何查找url jdbc:mysql:

public class KoneksiDatabase {
private static Connection koneksi;
public static Connection getKoneksi(){
    if (koneksi == null) {
        try {
            String url = "jdbc:mysql://localhost/universitas";
            String user = "root";
            String pasword = "kendo";

            DriverManager.registerDriver (new com.mysql.jdbc.Driver());
            koneksi = DriverManager.getConnection (url, user, pasword);
        } catch (SQLException t) {
            System.out.println ("Eror Java Database Connection");
        }

    }
    return koneksi;
}

1 个答案:

答案 0 :(得分:0)

您是否已将mysql-connector.jar文件添加到库中?它是默认java包中未包含的外部资源。