Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <%@ page language="java" contentType="text/html; charset=windows-1255"
- pageEncoding="windows-1255"%>
- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
- <%@ page import ="java.sql.*" %>
- <%!
- String connectionURL = "jdbc:mysql://localhost:3306/tomer";
- Connection connection = null;
- Statement statement = null;
- ResultSet rs = null;
- %>
- <%!
- void connectDB(){
- try {
- Class.forName ("com.mysql.jdbc.Driver").newInstance();
- connection =DriverManager.getConnection(connectionURL,"root","root");
- statement = connection.createStatement();
- }
- catch(Exception ex) {
- System.out.println("error in connecting");
- }
- }
- %>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=windows-1255">
- <title>LIST A SQL DATABASE</title>
- <link rel="stylesheet" type="text/css" href="dbtable.css" />
- </head>
- <body>
- <center><h1>Weapons List</h1>
- <div id=table>
- <table border="1" style="text-align: center;">
- <tr>
- <th>Name</th>
- <th>Year of production</th>
- <th>Army</th>
- <th>Estimated cost</th>
- <th>RPM</th>
- <th>Ammunition</th>
- </tr>
- <%
- connectDB();
- int no=0;
- rs = statement.executeQuery("SELECT * FROM users");
- while (rs.next()) {
- out.println("<tr>");
- out.println("<td>");
- out.println(rs.getString("username"));
- out.println("</td>");
- out.println("<td>");
- out.println(rs.getString("password"));
- out.println("</td>");
- out.println("<td>");
- out.println(rs.getString("fname"));
- out.println("</td>");
- out.println("<td>");
- out.println(rs.getString("lname"));
- out.println("</td>");
- out.println("<td>");
- out.println(rs.getString("email"));
- out.println("</td>");
- out.println("<td>");
- out.println(rs.getString("gender"));
- out.println("</td>");
- }
- rs.close();
- %>
- </table></div></center>
- <p>
- <center>
- <div id=delete>
- <form name="del" method="post" action="userdelete2.jsp" onsubmit="return dl()">
- <div id="databasetext">Enter the name of the weapon that you would like to delete</div>
- <input type="text" id="input1" name="name" style="background-color:#2E8B57;">
- <br><br>
- <INPUT TYPE="submit" id="in" value=""> <input type="reset" id="reset2" value="">
- </form>
- </div></center>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment