Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

upgraded tomcat from 5.0 to 5.5 and could not connect to DB

 
Elias Ta
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I upgraded from tomcat 5.0 to 5.5 and I am getting SQL exception "ERROR IN INITIALIZAING DB CONNECTION IN PAGESERVLET " as in the following sample code
try
{
InitialContext initialcontext = new InitialContext();
try
{
message.debug("getting context");
Context context = (Context)(new InitialContext()).lookup("java:comp/env");
message.debug("getting connection");
conn = ((DataSource)context.lookup("mydb")).getConnection();
message.debug("got connection");
processRequest(httpservletrequest, httpservletresponse);
}
catch(SQLException sqlexception)
{
message.error("ERROR: Initializing DB Connections in PageServlet");
}
finally
{
try
{
if(!conn.isClosed())
conn.close();
}
catch(SQLException sqlexception1) { }
}


a sample of my tomcat server.xml looks like this
<DefaultContext>
<Resource name="mydb" auth="container" type="javax.sql.DataSource" />

<ResourceParams name="mydb">

<parameter>
<name>driverClassName</name>
<value>oracle.jdbc.driver.OracleDriver</value>
</parameter>

<parameter>
<name>url</name>
<value>jdbcracle:thin:@10.3.4.5:1521:kwdev01</value>
</parameter>

<parameter>
<name>username</name>
<value>abc</value>
</parameter>

<parameter>
<name>password</name>
<value>abc</value>
</parameter>

<parameter>
<name>maxActive</name>
<value>200</value>
</parameter>

<parameter>
<name>maxIdle</name>
<value>50</value>
</parameter>

<parameter>
<name>maxWait</name>
<value>10000</value>
</parameter>

<parameter>
<name>removeAbandoned</name>
<value>true</value>
</parameter>

<parameter>
<name>removeAbandonedTimeout</name>
<value>300</value>
</parameter>

</ResourceParams>

</DefaultContext>
<!-- END ADDED FOR BRIGHTSERV -->
####################################

</Host>

</Engine>

</Service>

</Server>
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic