Guest User

Untitled

a guest
Dec 16th, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <%@ page import="java.io.*, java.util.*, java.sql.*, javax.servlet.http.*, javax.servlet.*" @>
  3. <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
  4. <%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql" %>
  5. <% Class.forName("com.mysql.jdbc.Driver").getInstance(); /* for good measure */ %>
  6. <html>
  7. <body>
  8. <sql:query dataSource="jdbc/foo" var="result">
  9. SELECT name FROM Users;
  10. </sql:query>
  11. <c:forEach var="r" items="${result.rows}">
  12. <c:out value="${r.name}"/><br/>
  13. </c:forEach>
  14. </body>
  15. </html>
  16.  
  17. <?xml version="1.0" encoding="utf-8"?>
  18. <Context>
  19. <Resource name="jdbc/foo" auth="Container" type="javax.sql.DataSource" maxTotal="64"
  20. maxIdle="16" maxWaitMillis="10000" username="user" password="password"
  21. driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/foo"/>
  22. </Context>
  23.  
  24. <?xml version="1.0" encoding="UTF-8"?>
  25. <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
  26. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  27. xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
  28. http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
  29. version="4.0"
  30. metadata-complete="true>
  31.  
  32. <request-character-encoding>UTF-8></request-character-encoding>
  33. <welcome-file-list>
  34. <welcome-file>index.jsp</welcome-file>
  35. </welcome-file-list>
  36. <resource-ref>
  37. <description>Database connection</description>
  38. <res-ref-name>jdbc/foo</res-ref-name>
  39. <res-type>javax.sql.DataSource</res-type>
  40. <res-auth>Container</res-auth>
  41. </resource-ref>
  42. </web-app>
Add Comment
Please, Sign In to add comment