Advertisement
Guest User

Untitled

a guest
Jul 28th, 2016
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.33 KB | None | 0 0
  1. <%@page import="com.mysql.jdbc.Connection"%>
  2. <%@page import="com.mysql.jdbc.Statement"%>
  3. <%@page import="java.sql.ResultSet"%>
  4. <%@page import="java.sql.DriverManager"%>
  5. <%@page contentType="text/html" pageEncoding="UTF-8"%>
  6. <!DOCTYPE html>
  7. <html>
  8. <head>
  9. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  10. <title>JSP Page</title>
  11. </head>
  12. <body>
  13. <h1>Hello World!</h1>
  14. <%@ page import ="java.sql.*" %>
  15. <%
  16. Connection c1 = null;
  17. Statement st = null;
  18. ResultSet rs = null;
  19.  
  20. Class.forName("com.mysql.jdbc.Driver");
  21. c1 = (Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/teacher","root", "abcde");
  22. {
  23. System.out.println("Couldn't find the driver!");
  24. System.out.println("Couldn't connect: print out a stack trace and exit.");
  25. System.out.println("We got an exception while creating a statement:" + "that probably means we're no longer connected.");
  26.  
  27. st = (Statement) c1.createStatement();
  28. System.out.println("Statement Created Successfully");
  29. {
  30. System.out.println("We got an exception while creating a statement:" + "that probably means we're no longer connected."); }
  31.  
  32. if (c1!= null) {
  33. System. out.println("Hooray! We connected to the database!");
  34. } else {
  35. System.out.println("We should never get here.");
  36. }}
  37. %>
  38. <%
  39. try{
  40.  
  41. String name=request.getParameter("username");
  42. String abc=request.getParameter("password");
  43. String Sql="select * from login where username='"+name+"' AND password='"+abc+"'";
  44.  
  45. while(rs.next()) {
  46. out.println("aa");}
  47. catch(SQLException ex)
  48. {
  49. out.println(ex);
  50. }
  51. %>
  52.  
  53. <%@page contentType="text/html" pageEncoding="UTF-8"%>
  54. <!DOCTYPE html>
  55. <html>
  56. <%@include file="db conn.jsp" %>
  57. <head>
  58. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  59. <title>JSP Page</title>
  60. </head>
  61. <body>
  62. <form method="GET " action="reg.jsp" autocomplete="on">
  63. <h1>Log in</h1>
  64. <p>
  65. <label for="username" class="uname" data-icon="u" >Username:</label>
  66. <input id="username" name="username" required="required" type="text" placeholder="Username"/>
  67. </p>
  68. <p>
  69. <label for="password" class="youpasswd" data-icon="p">Password:</label>
  70. <input id="password" name="password" required="required" type="password" placeholder="Password" />
  71. </p>
  72. <p class="keeplogin">
  73. <input type="checkbox" name="loginkeeping" id="loginkeeping" value="loginkeeping" />
  74. <label for="loginkeeping">Keep me logged in</label>
  75. </p>
  76. <p class="login button">
  77. <input type="submit" value="Login" />
  78. <input type="button" onclick="location.href='reg.jsp';" value="Sign Up"/>
  79. </p>
  80.  
  81. <input type="radio" name="gender" value="Teach" checked/> Teacher
  82. <input type="radio" name="gender" value="Student"/>Student
  83. </form>
  84. </body>
  85. </html>
  86.  
  87. HTTP Status 500 -
  88. type Exception report
  89.  
  90. message
  91.  
  92. description The server encountered an internal error () that prevented it from fulfilling this request.
  93.  
  94. exception
  95.  
  96. org.apache.jasper.JasperException: Exception in JSP: /db conn.jsp:62
  97.  
  98. 62: while(rs.next()) {}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement