× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hello All;
This is the first time I am trying connection pooling in WAS Express 6.0 and am running into a few problems. I have configured the datasource using the WAS console and tested the connection to be successful. In my next step I am trying to use that datasource but I am getting a naming exception. I am not sure if I am doing something wrong in the code itself or there is some kind of configuration change I need to make. I would be really grateful if anybody could point me in the right direction. Any help would be much appreciated. Here is the .jsp file.
******************************************
<%@ page language="java"
import="java.sql.*"
import= "java.io.IOException"
import= "org.apache.commons.lang.StringUtils"
import= "java.util.*"
import= "java.lang.*"


import="java.sql.Connection"
import="java.sql.ResultSet"
import="java.sql.SQLException"
import="java.sql.Statement"

import="javax.naming.Context"
import="javax.naming.InitialContext"
import="javax.naming.NamingException"
import="javax.sql.DataSource"


%>

<%


         try {
              Context ctx = new InitialContext();
DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/test2ds");
              Connection connection = ds.getConnection();
              Statement stmt = connection.createStatement();
ResultSet resultSet = stmt.executeQuery("select * from testing.books");
              while (resultSet.next()) {
                   String author = resultSet.getString("AUTHR");
                   String title = resultSet.getString("TITLE");
                   out.print(author + ": ");
                   out.print(title + " ");
              }
         } catch (NamingException e) {
              out.print("NAMINGEXCEPTION");
              e.printStackTrace();
         } catch (SQLException e) {
              out.print("SQLEXCEPTION");
              e.printStackTrace();
         }



         out.close();



%>

****************************************

Thanks in advance.

cheers,

Mike.

_________________________________________________________________
Stay up-to-date with your friends through the Windows Live Spaces friends list. http://clk.atdmt.com/MSN/go/msnnkwsp0070000001msn/direct/01/?href=http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mk


As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.