sudo apt-get install libmysql-java
To use the mysql connector java,we need to download in
Once we do we download the configuration in eclipse,like this :
- Select Project Properties > Java Build Path
- Select Libries tab
- Click Add External Jars
- Choose the jar file, in this case mysql-connector-java.java
package com.andia.oop;
/**
* connect to database mysqls
*/
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class ConnectionDatabases {
public static void main(String[] args) throws SQLException {
String url = "jdbc:mysql://localhost/datapribadi";
String user = "root";
String pass = "dendy";
Connection con = DriverManager.getConnection(url, user, pass);
System.out
.println("anda telah connect dengan database datapribadi");
con.close();
}
}
Ok.please..using mysql in java.