package rnb.cell;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
/**
*
* @author Azhar
*/
public class koneksi {
private static Connection konek;
public static Connection getkoneksi(){
if (konek == null ){
try{String url = "jdbc:mysql://localhost/gammu_db";
String user = "root";
String pass = "";
DriverManager.registerDriver(new com.mysql.jdbc.Driver());
konek = DriverManager.getConnection(url, user, pass);
System.out.println("succses");}
catch(SQLException t){
System.out.println("Error in connection");}
}
return konek;
}
public void close() throws SQLException{
konek.close();
}
}
pastikan telah ada library mysql-connector-java-5.1.18-bin.jar di folder lib
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
/**
*
* @author Azhar
*/
public class koneksi {
private static Connection konek;
public static Connection getkoneksi(){
if (konek == null ){
try{String url = "jdbc:mysql://localhost/gammu_db";
String user = "root";
String pass = "";
DriverManager.registerDriver(new com.mysql.jdbc.Driver());
konek = DriverManager.getConnection(url, user, pass);
System.out.println("succses");}
catch(SQLException t){
System.out.println("Error in connection");}
}
return konek;
}
public void close() throws SQLException{
konek.close();
}
}
pastikan telah ada library mysql-connector-java-5.1.18-bin.jar di folder lib
No comments:
Post a Comment