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 rentalmobil.user;
- import java.sql.*;
- import javax.swing.JOptionPane;
- /**
- *
- * @author surya
- */
- public class koneksi {
- private static Connection conn;
- public static Connection getconn(){
- if(conn == null){
- try{
- String url = "jdbc:mysql://localhost/rental_mobil";
- String user = "root";
- String password = "";
- DriverManager.registerDriver(new com.mysql.jdbc.Driver());
- DriverManager.getConnection(url,user,password);
- JOptionPane.showMessageDialog(null, "Koneksi berhasil !!!");
- }catch (SQLException t){
- JOptionPane.showMessageDialog(null, "Koneksi gagal !!!");
- }
- }
- return conn;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement