-1

I am newbie, is learning to make the program connect to the mysql database, but there is an error. i want to know how to look for 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;
}
Atenk941
  • 1
  • 2

1 Answers1

0

Have you added the mysql-connector.jar file into your Library? It's an external resource not included with the default java package.

Scott
  • 279
  • 3
  • 14
  • mysql-connector.jar file has been added to the library, but when in run error occurs. Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException – Atenk941 May 27 '18 at 02:57