Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.sql.*;
- public class database
- {
- Connection con;
- PreparedStatement pst;
- ResultSet rs;
- database()
- {
- try{
- Class.forName("com.mysql.jdbc.Driver");
- con=DriverManager.getConnection("jdbc:mysql://localhost/dbziy", "root", "");
- pst=con.prepareStatement("select * from karyawan where Username=? and Password=?");
- }
- catch (Exception e)
- {
- System.out.println(e);
- }
- }
- public Boolean checkLogin(String cb,String Password)
- {
- try {
- pst.setString(1, cb);
- pst.setString(2, Password);
- rs=pst.executeQuery();
- if(rs.next())
- {
- return true;
- }
- else
- {
- return false;
- }
- } catch (Exception e) {
- // TODO Auto-generated catch block
- System.out.println("error while validating"+e);
- return false;
- }
- }
- }
Add Comment
Please, Sign In to add comment