If you want to test your JNDI JDBC-Rsource use this servlet method as a reference:
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet TestDBServlet</title>");
out.println("</head>");
out.println("<body>");
out.println("Servlet TestDBServlet at " + request.getContextPath() + " ");
try {
InitialContext ctx = new InitialContext();
DataSource ds = (DataSource) ctx.lookup("jdbc/YourDataSource");
Connection connection = ds.getConnection();
Statement statement = connection.createStatement();
ResultSet rs = statement.executeQuery("select " + "usertable.userid,password,groupid " + "from usertable,grouptable where usertable.userid=grouptable.userid");
while(rs.next()) {
out.println("user, pw, group: " + rs.getString(1) + ", " + rs.getString(2) + ", " + rs.getString(3) + " ");
}
} catch (Exception ex) {
out.println("Got an Exception: " + ex);
} out.println("</body>");
out.println("</html>");
out.close();
}
[Message sent by forum member 'zebhed' (zebhed)]
http://forums.java.net/jive/thread.jspa?messageID=243680