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(
"jdbc:oracle: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>jdbc:oracle: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
-
Problems with Oracle 9i Thin Driver (3 messages)
- Posted by: Code Chimp
- Posted on: May 08 2003 20:57 EDT
Threaded Messages (3)
- Problems with Oracle 9i Thin Driver by Todd Story on May 09 2003 09:18 EDT
- Problems with Oracle 9i Thin Driver by Code Chimp on May 09 2003 11:32 EDT
- Problems with Oracle 9i Thin Driver by joseph yi on May 09 2003 03:32 EDT
- Problems with Oracle 9i Thin Driver by Code Chimp on May 09 2003 11:32 EDT
-
Problems with Oracle 9i Thin Driver[ Go to top ]
- Posted by: Todd Story
- Posted on: May 09 2003 09:18 EDT
- in response to Code Chimp
See the datasource howto in Tomcat's documentation:
http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-datasource-examples-howto.html
This explains everything quite well. -
Problems with Oracle 9i Thin Driver[ Go to top ]
- Posted by: Code Chimp
- Posted on: May 09 2003 11:32 EDT
- in response to Todd Story
Thanks,
I did look at that but it only explains 8i, I didn't think it would be an issue to go to 9i but it is. Which is why I ask the question.
What was listed on the Tomcat 5 Servlet/JSP Container - JNDI Datasource How-To did not help me with the problem.
Any other ideas would be appreciated.
CC -
Problems with Oracle 9i Thin Driver[ Go to top ]
- Posted by: joseph yi
- Posted on: May 09 2003 15:32 EDT
- in response to Code Chimp
I put the driver in the TOMCAT_HOME/common/lib directory.
Here's an excerpt out of my server.xml which shares an Oracle connection across multiple contexts (webapps). You'd probably need to change the username, password, and URL :)
<Engine ... >
<Host ... >
<DefaultContext>
<Resource name="dev" auth="Container"
type="javax.sql.DataSource" />
<ResourceParams name="dev">
<parameter>
<name>username</name>
<value>scott</value>
</parameter>
<parameter>
<name>password</name>
<value>tiger</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>10</value>
</parameter>
<parameter>
<name>maxWait</name>
<value>5000</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>2</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>oracle.jdbc.driver.OracleDriver</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:oracle:thin:@localhost:1521:dev</value>
</parameter>
</ResourceParams>
</DefaultContext>
<!-- Other Context related Stuff -->
</Host>
</Engine>