Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Configuring Connection Pool in TomCat

Status
Not open for further replies.

TarunAgarwal

Programmer
Nov 18, 2001
15
IN
Hi,

I am trying to configure the server.xml file to create a connection pool (Oracle database) and access the same through my java code. I am not able to do so. Can I get a sample code from somewhere which actually works? I have tried using lots of code from internet, but they dont work. I am attaching a code snippet, which DOES NOT work.

"server.xml"


<Context path=&quot;&quot; docBase=&quot;ROOT&quot; debug=&quot;0&quot;>
<Resource name=&quot;jdbc/BPIDb&quot; auth=&quot;Container&quot;
type=&quot;javax.sql.DataSource&quot;/>
<ResourceParams name=&quot;jdbc/BPIDb&quot;>
<parameter>
<name>user</name>
<value>tiecom</value>
</parameter>
<parameter>
<name>password</name>
<value>tiecom</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>oracle.jdbc.driver.OracleDriver</value>
</parameter>
<parameter>
<name>driverName</name>
<value>jdbc:eek:racle:thin:mad:172.25.42.23:1526:yellow</value>
</parameter>
</ResourceParams>

&quot;Java Code to access this&quot;

Context initCtx = new InitialContext();

Context envCtx = (Context) initCtx.lookup(&quot;java:comp/env&quot;);

DataSource ds = (DataSource) envCtx.lookup(&quot;jdbc/BPIDb&quot;);



Connection conn = ds.getConnection();



Here I get a null pointer for &quot;ds&quot;.

Also, I would like to use the code for configuring SQL server. What all parameters do I need to change for that? A sample code would be of great help.

Regards,
Tarun.
 
I suspect that you are using the Tomcat 4.1.x version. This is a bug in there - I had the same issue and after grappling for over a week over it had to revert to Tomcat 4.0.6 version where this code works without any issues
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top