Advertisement
Guest User

server side

a guest
Dec 5th, 2018
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. import javax.swing.*;
  2. import java.io.IOException;
  3. import java.io.PrintWriter;
  4. import java.net.ServerSocket;
  5. import java.net.Socket;
  6. import java.sql.*;
  7.  
  8. public class Server {
  9. public Connection koneksi;
  10.  
  11. public Server() throws ClassNotFoundException, SQLException {
  12. Class.forName("com.mysql.jdbc.Driver");
  13. koneksi = DriverManager.getConnection("jdbc:mysql://localhost:3306/pulsaapp","root","");
  14. }
  15.  
  16. public void Login(Integer id, String password) throws SQLException, ClassNotFoundException {
  17. String sql = "SELECT id,password FROM karyawan WHERE id = ? AND password = ?";
  18. PreparedStatement statement = koneksi.prepareStatement(sql);
  19. statement.setInt(1,id);
  20. statement.setString(2,password);
  21. ResultSet rs = statement.executeQuery();
  22. if(rs.next()) {
  23. new Dashboard();
  24. } else {
  25. JOptionPane.showMessageDialog(null,"Id Atau Password Salah");
  26. }
  27. }
  28.  
  29.  
  30.  
  31. public static void main(String[] args) throws IOException {
  32.  
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement