#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2003
    Posts
    15
    Rep Power
    0

    Problem with Tomcat and Oracle 9i


    Hello,

    I am running Tomcat and Oracle 9i. I am trying to get my connection pooling working so I can use a JNDI. But I am having a problem.

    When I include everything in a jsp file it connects to the database and produces a result.

    Connection conn = null;
    try
    {
    Class.forName("oracle.jdbc.driver.OracleDriver");

    conn = DriverManager.getConnection(
    "jdbcracle:thin:@xxx.xxx.xx.xx:1521:dev",
    "happy",
    "xxxx");

    When I have it in the Context I just get:
    A Java.nullpointerexception

    My server.xml is:
    <parameter>
    <name>url</name>
    <value>jdbcracle:thin:@xxx.xxx.xxx.xxx:1521:dev</value>
    </parameter>
    With the same parameters for username and password as above.

    My servlet is:
    Context ctx = new InitialContext();
    if(ctx == null )
    throw new Exception("Oops - No Context");

    DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/database");

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

    All your help is appreciated:
    CC
  2. #2
  3. No Profile Picture
    Clueless llama
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Feb 2001
    Location
    Lincoln, NE. USA
    Posts
    2,353
    Rep Power
    117
    I do not use Tomcat connection pooling as we use Websphere, but here is the how-to for JNDI connection pooling in Tomcat. Hope it helps
    http://jakarta.apache.org/tomcat/tom...les-howto.html

IMN logo majestic logo threadwatch logo seochat tools logo