Is this an issue encountered by users of tomcat 4.1.18.Le?  Should i try
reinstalling and configuring an earlier version?  I've see serveral
discussion regarding this topic and I've tried everything suggested... what
should I do now?

-----Original Message-----
From: Nicole Hibbard [mailto:[EMAIL PROTECTED]]
Sent: Monday, January 13, 2003 3:45 PM
To: Tomcat Users List; [EMAIL PROTECTED]
Subject: RE: Name jdbc:comp is not bound in this context


Thanks for the reply :).  Unfoutunately I added the useNaming="true and I
still have the same results. I'm really stuck here... do you have any other
suggestions.

-----Original Message-----
From: Justin L. Spies [mailto:[EMAIL PROTECTED]]
Sent: Monday, January 13, 2003 3:31 PM
To: 'Tomcat Users List'
Subject: RE: Name jdbc:comp is not bound in this context


Nicole,
Not sure if this was answered, but I'll give it a try.  When I had this
problem, I found that I needed to add useNaming="true" to both the <Host
...> entry and to the <Context ...> entry.

Sincerely,
Pantek Incorporated
Justin L. Spies

URL: http://www.pantek.com
Ph   440.519.1802
Fax  440.248.5274
Cell 440.336.3317

-----Original Message-----
From: Nicole Hibbard [mailto:[EMAIL PROTECTED]]
Sent: Monday, January 13, 2003 3:11 PM
To: [EMAIL PROTECTED]
Subject: Name jdbc:comp is not bound in this context


I've gone through every resource I have in trying to test a connection
to MySql database.

I am using Tomcat 4.1.18-LE and MySql 3.23.53 and java 1.4.1_01.

I set priveleges on MySql, put the mm.sql driver's jar in common/lib. I
set my Classpath Variable

.;C:\ServletDev;C:\jakarta-tomcat-4.1.18-LE-jdk14\common\lib\servlet.jar
;C:\
mysql-connector-java-2.0.14\mysql-connector-java-2.0.14-bin.jar

I added the following to my server.xml


<!--1/07/2002  Nicole Hibbard
            The following block of code add the datasource for
connecting
            mysql database using Connector J Driver -->

        <Context path="/DBTest" docBase="DBTest"
                debug="5" reloadable="true" crossContext="true">

        <Logger className = "org.apache.catalina.logger.FileLogger"
                prefix="localhost_DBTest_log." suffix=".txt"
                timestamp="true"/>
        <Resource name="jdbc/TestDB"
                auth="Container"
                type="javax.sql.DataSource"/>

        <ResourceParams name = "jdbc/TestDB">
                <parameter>
                  <name>factory</name>

<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
                </parameter>

        <!--Maximum number of dBconnections in pool.  Make sure you
configure your
            mysqld max_connection large enough to handle all you
connections-->

                <parameter>
                  <name>maxActive</name>
                  <value>100</value>
                </parameter>

                <parameter>
                  <name>password</name>
                  <value>javadude</value>
                </parameter>

        <!-- Class name for JDBC driver -->

                <parameter>
                  <name>driverClassName</name>
                  <value>com.mysql.jdbc.Driver</value>
                </parameter>

        <!--  The JDBC connection url for connecting to your mysql db
                if the connection closes then auto connect -->

                <parameter>
                  <name>url</name>

<value>jdbc:mysql://localhost/javatest?user=javauser</value>
                </parameter>

        </ResourceParams>

        </Context>

        <!--End of code from 1/7/2003 for Nicole Hibbard-->

I created a web.xml in DBTest/WEB-INF

<?xml version="1.0" encoding="ISO-8859-1"?>
        <!DOCTYPE web-app PUBLIC
        "-//Sun Microsystems, Inc.//DTD Web Application 2.3//DN"
        "http://java.sun.com/dtd/web-app_2_3.dtd";>
<web-app>

        <description>MySQL Test App </description>
        <resource-ref>
                <description>DB Connection</description>
                <res-ref-name>jdbc/TestDB</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Container</res-auth>
</resource-ref>
</web-app>

I have a jsp in web-apps/DBTest

<html>
  <head>
    <title>DB Test</title>
  </head>
  <body>

  <%
    foo.DBTest tst = new foo.DBTest();
    tst.init();
  %>

  <h2>Results</h2>
    Foo <%= tst.getFoo() %><br/>
    Bar <%= tst.getBar() %>


  </body>
</html>


I have a DBTest.class in Webapps/DBtest/foo

package foo;

import javax.naming.*;
import javax.sql.*;
import java.sql.*;

public class DBTest {

  String foo = "Not Connected";
  int bar = -1;

  public void init() {
    try{
      Context ctx = new InitialContext();
      if(ctx == null )
          throw new Exception("Boom - No Context");

      DataSource ds =
            (DataSource)ctx.lookup(
               "java:comp/env/jdbc/TestDB");
      if (ds == null) foo= "Datasource is null";

      if (ds != null) {
        Connection conn = ds.getConnection();

      if (conn == null) foo="got datasource, no connection";
        if(conn != null)  {
            foo = "Got Connection "+conn.toString();
            Statement stmt = conn.createStatement();
            ResultSet rst =
                stmt.executeQuery(
                  "select id, foo, bar from testdata");
            if(rst.next()) {
               foo=rst.getString(2);
               bar=rst.getInt(3);
            }
            conn.close();
        }
      }
    }catch(Exception e) {
      e.printStackTrace();
    }
 }

 public String getFoo() { return foo; }
 public int getBar() { return bar;}
}

AND I GET THE FOLLOWING ERROR ON TOMCAT

javax.naming.NameNotFoundException: Name jdbc:comp is not bound in this
Context

My test.jsp outputs

Results
Foo Not Connected
Bar -1

I have to get this working ASAP!!  Please help!

Nicole





--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>



--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>


--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to