Membuat Class Koneksi ke Database
package
project_penjualan;
import
java.sql.*;
/**
*
* @author ismail
*/
public class
ConekDB {
public static void main(String[] args){
}
public Connection konek()throws
SQLException{
Connection Cn=null;
try{
Class.forName("com.mysql.jdbc.Driver");
System.out.println("driver
berhasil ditemukan");
try{
String
url="jdbc:mysql://localhost/penjualan";
String user="root";
String
password="";
Cn=DriverManager.getConnection(url, user, password);
System.out.println("buat koneksi sukses");
return Cn;
}catch(SQLException ex){
System.out.println("koneksi
gagal");
System.out.println("SQLException:"+ ex.getMessage());
return null;
}
}catch(Exception se){
System.out.println("Driver
MySQL tidak ditemukan:"+se);
return null;
}
}
}
Selanjutnya membuat
class data java
/*
* To change this template, choose Tools |
Templates
* and open the template in the editor.
*/
package
project_penjualan;
import
java.sql.*;
import
javax.swing.*;
/**
*
* @author ismail
*/
public class
Data {
Connection cnExecute=null;
int rowNgefek=0;
Statement stExecute;
public void closingConnection(Connection
cnClose,Statement stClose)
{
try
{
cnClose.close();
stClose.close();
}
catch(SQLException e)
{
}
}
public void ExecuteSQL(String SQL)
{
ConekDB getCn=new ConekDB();
rowNgefek=0;
try{
cnExecute=getCn.konek();
stExecute=cnExecute.createStatement();
cnExecute.setAutoCommit(false);
rowNgefek=stExecute.executeUpdate(SQL);
cnExecute.commit();
closingConnection(cnExecute,stExecute);
}
catch(SQLException e)
{
System.out.println(e.toString());
JOptionPane.showMessageDialog(null,
e.toString(),"warning",JOptionPane.OK_OPTION);
}
}
}


Harrah's Las Vegas Casino & Hotel - Mapyro
BalasHapusHotel. Harrah's Las Vegas Casino & Hotel is situated in Las Vegas, NV, 통영 출장마사지 3 miles from McCarran International Airport. 전라북도 출장마사지 The casino hotel 강릉 출장샵 is 7.6 mi (10.8 안양 출장마사지 km) from Rating: 4.1 · 22 reviews · Price range: room rates from $48 per night (USD) 이천 출장마사지 - We Price Match!