Advertisement
Guest User

Untitled

a guest
Feb 12th, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  5. <title>Insert title here</title>
  6. </head>
  7. <body>
  8.  
  9. </body>
  10. <form method="post">
  11.  
  12. <table border="2">
  13. <tr>
  14. <td>ID</td>
  15. <td>NAME</td>
  16. <td>SKILL</td>
  17. <td>ACTION</td>
  18. </tr>
  19. <%
  20. try
  21. {
  22. Class.forName("com.mysql.jdbc.Driver");
  23. String url="jdbc:mysql://localhost/test";
  24. String username="root";
  25. String password="root";
  26. String query="select * from jsp1";
  27. Connection conn=DriverManager.getConnection(url,username,password);
  28. Statement stmt=conn.createStatement();
  29. ResultSet rs=stmt.executeQuery(query);
  30. while(rs.next())
  31. {
  32.  
  33. %>
  34. <tr><td><%rs.getInt("ID"); %></td></tr>
  35. <tr><td><%rs.getString("NAME"); %></td></tr>
  36. <tr><td><%rs.getString("SKILL"); %></td></tr>
  37. <%
  38.  
  39. }
  40. %>
  41. </table>
  42. <%
  43. rs.close();
  44. stmt.close();
  45. conn.close();
  46. }
  47. catch(Exception e)
  48. {
  49. e.printStackTrace();
  50. }
  51.  
  52.  
  53.  
  54.  
  55. %>
  56.  
  57. </form>
  58. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement