Guest User

Untitled

a guest
Jun 16th, 2013
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.17 KB | None | 0 0
  1. <%@ page language="java" contentType="text/html; charset=windows-1255"
  2. pageEncoding="windows-1255"%>
  3. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  4. <%@ page import ="java.sql.*" %>
  5. <%!
  6. String connectionURL = "jdbc:mysql://localhost:3306/tomer";
  7. Connection connection = null;
  8. Statement statement = null;
  9. ResultSet rs = null;
  10. %>
  11.  
  12. <%!
  13. void connectDB(){
  14. try {
  15. Class.forName ("com.mysql.jdbc.Driver").newInstance();
  16. connection =DriverManager.getConnection(connectionURL,"root","root");
  17. statement = connection.createStatement();
  18. }
  19. catch(Exception ex) {
  20. System.out.println("error in connecting");
  21. }
  22. }
  23. %>
  24.  
  25. <html>
  26. <head>
  27.  
  28. <meta http-equiv="Content-Type" content="text/html; charset=windows-1255">
  29. <title>LIST A SQL DATABASE</title>
  30. <link rel="stylesheet" type="text/css" href="dbtable.css" />
  31. </head>
  32. <body>
  33. <center><h1>Weapons List</h1>
  34.  
  35. <div id=table>
  36. <table border="1" style="text-align: center;">
  37. <tr>
  38. <th>Name</th>
  39. <th>Year of production</th>
  40. <th>Army</th>
  41. <th>Estimated cost</th>
  42. <th>RPM</th>
  43. <th>Ammunition</th>
  44. </tr>
  45. <%
  46. connectDB();
  47. int no=0;
  48. rs = statement.executeQuery("SELECT * FROM users");
  49. while (rs.next()) {
  50. out.println("<tr>");
  51. out.println("<td>");
  52. out.println(rs.getString("username"));
  53. out.println("</td>");
  54. out.println("<td>");
  55. out.println(rs.getString("password"));
  56. out.println("</td>");
  57. out.println("<td>");
  58. out.println(rs.getString("fname"));
  59. out.println("</td>");
  60. out.println("<td>");
  61. out.println(rs.getString("lname"));
  62. out.println("</td>");
  63. out.println("<td>");
  64. out.println(rs.getString("email"));
  65. out.println("</td>");
  66. out.println("<td>");
  67. out.println(rs.getString("gender"));
  68. out.println("</td>");
  69. }
  70. rs.close();
  71. %>
  72. </table></div></center>
  73. <p>
  74.  
  75. <center>
  76. <div id=delete>
  77. <form name="del" method="post" action="userdelete2.jsp" onsubmit="return dl()">
  78. <div id="databasetext">Enter the name of the weapon that you would like to delete</div>
  79. <input type="text" id="input1" name="name" style="background-color:#2E8B57;">
  80. <br><br>
  81. <INPUT TYPE="submit" id="in" value="">&nbsp;&nbsp;&nbsp;<input type="reset" id="reset2" value="">
  82. </form>
  83. </div></center>
  84. </body>
  85. </html>
Advertisement
Add Comment
Please, Sign In to add comment