%@page import="javax.naming.*, javax.sql.*, java.sql.*;" %>
SimplePool JNDI Example
<%
// Get a new initial JNDI context
Context ctx = new InitialContext();
// Get a reference to our JNDI DataSource
DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/JNDIPoolDS");
// Get a connection from the pool
Connection conn = ds.getConnection();
// Create a new statement
Statement stmt = conn.createStatement();
// Execute the query
ResultSet rst = stmt.executeQuery("SHOW TABLES");
%>
Tables
<%
// Loop through the result set and
// display the current column value
while (rst.next()) {
%>
- <%= rst.getString(1) %>
<%
}
%>
<%
// Close the result set, statement and connection
rst.close();
stmt.close();
conn.close();
%>