package m1;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
private void btnOkeActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Connection koneksi;
String database=txtNama.getText().trim();
String konek="jdbc:mysql://localhost:3306/"+ database;
String user = txtUser.getText().trim();
String pass =txtPassword.getText().trim();
try{
Class.forName("com.mysql.jdbc.Driver");
koneksi=DriverManager.getConnection(konek,user,pass);
JOptionPane.showMessageDialog(null, "Koneksi Berhasil");
}catch(ClassNotFoundException ex){
Logger.getLogger(FKoneksi.class.getName()).log(Level.SEVERE,null, ex);
JOptionPane.showMessageDialog(null, "Driver Tidak Ada");
}catch(SQLException ex){
Logger.getLogger(FKoneksi.class.getName()).log(Level.SEVERE,null, ex);
JOptionPane.showMessageDialog(null, "Koneksi Gagal");
}
}
private void btnTutupActionPerformed(java.awt.event.ActionEvent evt) {
System.exit(0);
}
And here is the result :
Tidak ada komentar:
Posting Komentar