Jasa Pembuatan dan Bimbingan Skripsi Informatika

Home » Linux » Koneksi Netbeans dan Mysql di Ubuntu

Koneksi Netbeans dan Mysql di Ubuntu


langkah-langkah :
1. Install netbeans
2. Install JDBC
dengan cara : sudo apt-get install libmysql-java

3. setting classpath : export CLASSPATH=.:/usr/share/java/mysql-connector-java.jar
4. buka netbeans , buat project dan file java
5. Tulis :
* To change this template, choose Tools | Templates
* and open the template in the editor.

package latihan2;

* @author abri
import java.sql.Connection;
import java.sql.Driver;
import java.sql.DriverManager;
import java.sql.SQLException;

public class testkoneksi {
public static void main (String[] args) throws Exception {
try {
Driver driver = (Driver) Class.forName (“com.mysql.jdbc.Driver”).newInstance();

String url = “jdbc:mysql://localhost:3306/test”;
String username = “root”;
String password = “”;

Connection connection = DriverManager.getConnection(url, username, password);
System.out.println(“KONEKSI BERHASIL”);

} catch (SQLException ex) {
System.out.println(“KONEKSI GAGAL”);

6. clean and buid
7. run


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: