Guest User

Untitled

a guest
Jan 11th, 2016
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. import java.sql.*;
  2.  
  3. public class validate
  4. {
  5. public static boolean checkUser(String email,String pass)
  6. {
  7. boolean st =false;
  8. try{
  9.  
  10. //loading drivers for mysql
  11. Class.forName("com.mysql.jdbc.Driver");
  12.  
  13. //creating connection with the database
  14. Connection con=DriverManager.getConnection
  15. ("jdbc:mysql://localhost:3306/test2","root","sa");
  16. PreparedStatement ps =con.prepareStatement
  17. ("select * from user_tbl where email=? and pass=?");
  18. ps.setString(1, email);
  19. ps.setString(2, pass);
  20. ResultSet rs =ps.executeQuery();
  21. st = rs.next();
  22.  
  23. }catch(Exception e)
  24. {
  25. e.printStackTrace();
  26. }
  27. return st;
  28. }
  29. }
Add Comment
Please, Sign In to add comment