Guest User

Untitled

a guest
May 24th, 2018
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. <%@ page import="java.sql.*" %>
  2. <%@ page import="java.io.*" %>
  3.  
  4. <%
  5. String user = request.getParameter("user");
  6.  
  7.  
  8. String url = "jdbc:mysql://localhost:3306/bigul";
  9. String userid = "root";
  10. String passDB = "root";
  11. String passFromDB = "";
  12.  
  13.  
  14. Statement stmt;
  15. String retriv = "Select * from info where username = '"+user+"'";
  16.  
  17. try {
  18. Class.forName("com.mysql.jdbc.Driver");
  19. }
  20. catch(java.lang.ClassNotFoundException e)
  21. { System.err.print("ClassNotFoundException: " + e.getMessage()); }
  22.  
  23.  
  24. try {
  25. Connection con = DriverManager.getConnection(url, userid, passDB);
  26. stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
  27. ResultSet rs = stmt.executeQuery(retriv);
  28. rs.next();
  29.  
  30. passFromDB = rs.getString("Password");
  31.  
  32. stmt.close();
  33. con.close();
  34. }
  35. catch(SQLException ex) { System.err.println("SQLException: " + ex.getMessage()); }
  36.  
  37.  
  38. String password = request.getParameter("pass");
  39.  
  40. if(passFromDB.equals(password) && !(password.equals("") && user.equals("")))
  41. {
  42. response.sendRedirect("Home.jsp");
  43.  
  44.  
  45.  
  46. }
  47. else
  48. {
  49. response.sendRedirect("LogIn.jsp");
  50. }
  51.  
  52. %>
Add Comment
Please, Sign In to add comment