Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * 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 dnacoffee;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- import java.sql.Statement;
- import javax.swing.JOptionPane;
- /*
- *
- * @author Bagos
- */
- public class Koneksi {
- private static Connection conn;
- public static Connection getConnection(){
- String url = "oracle.jdbc.driver.OracleDriver";
- String database = "jdbc:oracle:thin:@localhost:1521:XE";
- String username = "bagus_6628";
- String password = "admin";
- try{
- conn = (Connection) DriverManager.getConnection(database,username,password);
- }catch (SQLException err){
- JOptionPane.showMessageDialog(null, "GAGAL KONEKSI!!!");
- }
- return conn;
- }
- void putData(String sql){
- try{
- Connection con = getConnection();
- Statement state = con.createStatement();
- state.executeUpdate(sql);
- state.close();
- } catch(Exception ex){
- }
- }
- public Statement state;
- public ResultSet getData(String sql) throws Exception {
- Connection con = getConnection();
- state = con.createStatement();
- ResultSet rset = state.executeQuery(sql);
- return rset;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement