Vikhyath_11

8

Jul 28th, 2024 (edited)
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. <html>
  2. <head>
  3. <title>JDBC</title>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. </head>
  7. <body>
  8. <form action="jdbc.jsp" method="post">
  9. username:<input type="text" name="name">
  10. password:<input type="password" name="pwd">
  11. Submit:<input type="submit" value="Submit">
  12. </form>
  13. </body>
  14. </html>
  15.  
  16.  
  17.  
  18.  
  19.  
  20. <%@page contentType="text/html" pageEncoding="UTF-8"%>
  21. <!DOCTYPE html>
  22. <html>
  23. <head>
  24. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  25. <title>JSP Page</title>
  26. </head>
  27. <body>
  28. <%@page import = "java.sql.*"%>
  29. <%@page import = "javax.sql.*"%>
  30. <%
  31. String usr=request.getParameter("name");
  32. String pwd=request.getParameter("pwd");
  33. Class.forName("com.mysql.jdbc.Driver");
  34. java.sql.Connection con =
  35. DriverManager.getConnection("jdbc:mysql://localhost:3306/student","root","root");
  36. Statement st= con.createStatement();
  37. ResultSet rs= st.executeQuery("select * from login where username='"+usr+"'");
  38. if(rs.next()){
  39. if(rs.getString(2).equals(pwd)){
  40. session.setAttribute("user",rs.getString(1));
  41. String name = (String)session.getAttribute("user");
  42. out.println("Welocome Boss "+name);
  43. }
  44. else{
  45. System.out.println("Invalid");
  46. }
  47. }
  48. %></body>
  49. </html>
Advertisement
Add Comment
Please, Sign In to add comment