Results 1 to 1 of 1
  1. #1
    Join Date
    Dec 2002

    Question Unanswered: Tomcat JNDI + SQL Server

    I am trying to lookup a datasource in a servlet for SQLServer from the JNDI tree using tomcat 4.1 LE. However, I get the following exception:

    javax.naming.NamingException: Cannot create resource instance

    Here is what I think is the revelant info. If anyone has any idea I would really appreciate it, google is turning up empty. I have done this before with BEA without a problem.

    I have a ODBC connection with the name MustangGT that is working fine with my ASP app. I have also tried this using the JdbcOdbc bridge but still get the same error.


    Begin server.xml -------------------------------------------------------
    <Resource name="MustangGT" scope="Shareable" type="javax.sql.DataSource"/>
    <ResourceParams name="MustangGT">
    <value> r</value>

    End server.xml ---------------------------------------------------------------

    Begin servlet code -----------------------------------------------------------

    try {
    Context ctx = new InitialContext();
    Context envCtx = (Context)ctx.lookup("java:comp/env");
    DataSource ds = (DataSource)envCtx.lookup("MustangGT");
    Connection con = ds.getConnection();
    Statement stmt = con.createStatement();
    ResultSet res = stmt.executeQuery( "SELECT * FROM PROJECTS" );
    while( ) {
    String col2 = res.getString( 1 );
    writeHTML( col2 + "<br>", response );
    } catch( Exception e ) {

    End servlet code---------------------------------------------------------------
    Last edited by white_2kgt; 12-13-02 at 00:45.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts