Intial import.
This commit is contained in:
parent
db614924ac
commit
7e5f191232
28 changed files with 3411 additions and 0 deletions
45
simplepool/simplepool-examples/jndi/scriptlet.jsp
Normal file
45
simplepool/simplepool-examples/jndi/scriptlet.jsp
Normal file
|
@ -0,0 +1,45 @@
|
|||
<%@page import="javax.naming.*, javax.sql.*, java.sql.*;" %>
|
||||
<html>
|
||||
<head>
|
||||
<title>SimplePool JNDI Example</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<%
|
||||
// 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");
|
||||
%>
|
||||
|
||||
<h3>Tables</h3>
|
||||
<ul>
|
||||
<%
|
||||
// Loop through the result set and
|
||||
// display the current column value
|
||||
while (rst.next()) {
|
||||
%>
|
||||
<li><%= rst.getString(1) %></li>
|
||||
<%
|
||||
}
|
||||
%>
|
||||
<ul>
|
||||
|
||||
<%
|
||||
// Close the result set, statement and connection
|
||||
rst.close();
|
||||
stmt.close();
|
||||
conn.close();
|
||||
%>
|
||||
</body>
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue