Guest User

Untitled

a guest
Apr 15th, 2017
23
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.08 KB | None | 0 0
  1. <%--
  2.     Document   : newjsp
  3.     Created on : Apr 15, 2017, 1:14:17 PM
  4.     Author     : Spyweeb
  5. --%>
  6.  
  7. <%@page import="java.sql.DriverManager"%>
  8. <%@page import="java.sql.ResultSet"%>
  9. <%@page import="java.sql.Statement"%>
  10. <%@page import="java.sql.Connection"%>
  11. <%@page contentType="text/html" pageEncoding="UTF-8"%>
  12. <!DOCTYPE html>
  13. <html>
  14.     <head>
  15.         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  16.         <title>JSP Page</title>
  17.         <style>
  18.             th,tr,td
  19.             {
  20.                 font-family: Lucida Sans;
  21.             }
  22.             th{
  23.                 background-color: aquamarine;
  24.             }
  25.         </style>
  26.     </head>
  27.     <%!
  28.         Connection conn;
  29.         Statement stmt;
  30.         ResultSet rs;
  31.        
  32.          public Connection getCon(){
  33.              try{
  34.                  Class.forName("oracle.jdbc.OracleDriver");
  35.                  conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl", "hr", "ntic");
  36.              }catch(Exception e){
  37.                  e.printStackTrace();
  38.              }
  39.              return conn;
  40.          }
  41.     %>
  42.    
  43.     <%
  44.             try{
  45.                 stmt = getCon().createStatement();
  46.                 rs = stmt.executeQuery("SELECT first_name, job_id FROM employees");
  47.                
  48.     %>
  49.     <body>
  50.         <div align="center">
  51.         <table border="1" cellpadding="9" style="border-collapse: collapse">
  52.             <tbody>
  53.                 <tr>
  54.                     <th></th>
  55.                     <th>First Name</th>
  56.                     <th>Job</th>
  57.                 </tr>
  58.                 <% while(rs.next()){%>
  59.                 <tr>
  60.                     <td><input type="checkbox" name="" value="ON" /></td>
  61.                     <td> <%= rs.getString("first_name") %> </td>
  62.                     <td> <%= rs.getString("job_id") %> </td>
  63.                 </tr>
  64.                 <% } %>
  65.             </tbody>
  66.         </table>
  67.     <%
  68.             }catch(Exception ex){
  69.                 ex.printStackTrace();
  70.             }
  71.     %>
  72.         </div>
  73.     </body>
  74. </html>
Add Comment
Please, Sign In to add comment