Home > Java Programming > Get Connection MySQL

Get Connection MySQL


/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package mysql;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class CobaSQL {

private static Connection conn;

public static void main(String[] args) {
try {
conn = DriverManager.getConnection(“jdbc:mysql://localhost/db_kursus?user=root&password=”);
System.out.println(“Driver ditemukan. Koneksi berhasil!!!”);
} catch (SQLException ex) {
// handle any errors
System.out.println(“SQLException: ” + ex.getMessage());
System.out.println(“SQLState: ” + ex.getSQLState());
System.out.println(“VendorError: ” + ex.getErrorCode());
}
}
}

  1. No comments yet.
  1. No trackbacks yet.

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 )

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

Follow

Get every new post delivered to your Inbox.