Advertisement
Guest User

Untitled

a guest
Dec 4th, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.88 KB | None | 0 0
  1. public static boolean validateUser( String username, String pass)
  2.     {  
  3.         boolean found = false;
  4.         Connection c = DBHelperClass.getConnection();
  5.         if(c!=null)
  6.         {
  7.             try
  8.             {
  9.                 String template = "SELECT * from users where username=? and password=?";
  10.                 PreparedStatement inserter = c.prepareStatement(template);
  11.                 inserter.setString(1, username);
  12.                 inserter.setString(2, pass);
  13.                 ResultSet resultSet = inserter.executeQuery();
  14.                
  15.                 if (resultSet != null)
  16.                 {
  17.                     found = true;  
  18.                 }
  19.             }
  20.             catch (SQLException ex)
  21.             {
  22.                 Logger.getLogger(User.class.getName()).log(Level.SEVERE, null, ex);
  23.             }
  24.         }
  25.         return found;
  26.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement