Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.sql.*;
- /**
- *
- * @author RPL
- */
- public class koneksi {
- public static Connection setKoneksi(){
- Connection cn =null;
- try{
- Class.forName("com.mysql.jdbc.Driver");
- cn = (Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/db_buku","root","");
- }catch(Exception e){
- System.out.println(e);
- }
- return cn;
- }
- public static int execute(String SQL){
- int status = 0;
- try{
- Connection cn = setKoneksi();
- Statement st = cn.createStatement();
- status = st.executeUpdate(SQL);
- }catch(Exception e){
- System.out.println(e);
- }
- return status;
- }
- public static ResultSet executeQuery(String SQL){
- ResultSet rs = null ;
- Connection cn = setKoneksi();
- try{
- Statement st = cn.createStatement();
- rs = st.executeQuery(SQL);
- }catch(Exception e){
- System.out.println(e);
- }
- return rs;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement