Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <%@ page import="java.io.*, java.util.*, java.sql.*, javax.servlet.http.*, javax.servlet.*" @>
- <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
- <%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql" %>
- <% Class.forName("com.mysql.jdbc.Driver").getInstance(); /* for good measure */ %>
- <html>
- <body>
- <sql:query dataSource="jdbc/foo" var="result">
- SELECT name FROM Users;
- </sql:query>
- <c:forEach var="r" items="${result.rows}">
- <c:out value="${r.name}"/><br/>
- </c:forEach>
- </body>
- </html>
- <?xml version="1.0" encoding="utf-8"?>
- <Context>
- <Resource name="jdbc/foo" auth="Container" type="javax.sql.DataSource" maxTotal="64"
- maxIdle="16" maxWaitMillis="10000" username="user" password="password"
- driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/foo"/>
- </Context>
- <?xml version="1.0" encoding="UTF-8"?>
- <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
- http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
- version="4.0"
- metadata-complete="true>
- <request-character-encoding>UTF-8></request-character-encoding>
- <welcome-file-list>
- <welcome-file>index.jsp</welcome-file>
- </welcome-file-list>
- <resource-ref>
- <description>Database connection</description>
- <res-ref-name>jdbc/foo</res-ref-name>
- <res-type>javax.sql.DataSource</res-type>
- <res-auth>Container</res-auth>
- </resource-ref>
- </web-app>
Add Comment
Please, Sign In to add comment