Friday, April 1, 2016

Cara membuat koneksi Java ke MySQL

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package koneksi;
import java.sql.*;
/**
 *
 * @author Maleky
 */
public class DB_form {
    public Connection cc;
    public Statement ss;
    public ResultSet rs;
   
    public void Class(){
        try{
            Class.forName("com.mysql.jdbc.Driver");
            cc = DriverManager.getConnection("jdbc:mysql://localhost/biodata","root","");
            System.out.println("Koneksi Berhasil");
        }catch(Exception ex){
            System.out.println("Error: "+ex.getMessage());
        }
    }
   
}

No comments:

Post a Comment