Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- try{
- Class.forName("com.mysql.jdbc.Driver").newInstance();
- Connection conn= DriverManager.getConnection("jdbc:mysql://localhost:3306/database?zeroDateTimeBehavior=convertToNull","root","");
- Statement state= conn.createStatement();
- String sql="SELECT * FROM login where username="+"'"+nama.getText()+"'"+"AND katasandi="+"'"+pw.getText()+"'";
- ResultSet rs = state.executeQuery(sql);
- String user = null;
- String pass = null;
- while(rs.next()){
- user = rs.getString(1);
- pass = rs.getString(2);
- }
- if(!user.equals(null)&& !pass.equals(null))
- {
- this.setVisible(false);
- new MENU().setVisible(true);
- }
- else {
- JOptionPane.showMessageDialog(null,"Username Password Salah");
- nama.setText("");
- pw.setText("");
- nama.requestFocus();
- }
- }
- catch (Exception e)
- {
- JOptionPane.showMessageDialog(null,"Username Password Salah"+e.getMessage());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement