<%@ page import="javax.naming.Context"%> <%@ page import="javax.sql.DataSource"%> <%@ page import="javax.naming.InitialContext"%> <%@ page import="java.sql.*"%> <% DataSource ds = null; try { Context initCtx = new InitialContext(); Context envCtx = (Context) initCtx.lookup("java:comp/env"); ds = (DataSource) envCtx.lookup("IMDB"); if (ds != null) { out.println("Connection is OK! "); Connection cn = ds.getConnection(); if (cn != null) { out.println("cn is Ok! "); Statement stmt = cn.createStatement(); ResultSet rst = stmt .executeQuery("select * from dual "); out.println(" <p> rst is Ok! "); while (rst.next()) { out.println(" <P> test: " + rst.getString(1)); } cn.close(); } else { out.println("rst Fail! "); } } else out.println("Fail! "); } catch (Exception ne) { out.println(ne); } %>