<%@page contentType="text/html"%> 

<%@ page import="java.sql.*, javax.sql.DataSource, javax.naming.InitialContext" %> 

<h3>Test Oracle DB</h3> 

<% 
InitialContext ctx = new InitialContext(); 
DataSource ds = (DataSource) ctx.lookup("java:/OracleDS"); //注意这里哦和前面对应 
Connection conn = ds.getConnection(); 

Statement stmt = conn.createStatement(); 
ResultSet rs = stmt.executeQuery("SELECT * FROM Principals"); 

while ( rs.next() ) { 
out.println( rs.getString("PrincipalID") + "<br>"); 

} 

conn.close(); 
%> 
