Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. <%--
  2. Document : testdatabase
  3. Created on : Sep 25, 2015, 11:42:06 AM
  4. Author : Krishnan
  5. --%>
  6.  
  7. <%@ page import="java.lang.*" %>
  8. <%@ page import="java.sql.*" %>
  9. <%@ page import="java.io.*" %>
  10.  
  11.  
  12. <%! Connection con=null; %>
  13. <%! Statement st= null; %>
  14. <%! ResultSet rs= null; %>
  15.  
  16. <%@page contentType="text/html" pageEncoding="UTF-8"%>
  17. <!DOCTYPE html>
  18. <html>
  19. <head>
  20. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  21. <title>JSP Page</title>
  22. </head>
  23. <body>
  24. <%
  25. try
  26. {
  27. Class.forName("com.mysql.jdbc.Driver").newInstance();
  28. con = DriverManager.getConnection("jdbc:mysql://localhost:3306/dbuitmjasin?user=root&password=");
  29.  
  30. st = con.createStatement();
  31. rs = st.executeQuery("select * from usermaster");
  32.  
  33. while(rs.next()) {
  34. String name = rs.getString(1);
  35. out.println("<p>" + name );
  36. } // end of whilee
  37. rs.close();
  38. st.close();
  39. con.close();
  40.  
  41. }catch(SQLException e)
  42. {
  43. e.printStackTrace();
  44. }
  45. %>
  46.  
  47. </body>
  48. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement