tags:

views:

65

answers:

1

I have a website hosted at Godaddy where I use JNDI to manage DB connections. Godaddy is using Tomcat 5.5.27 with JDK 1.5. I am also using the same versions locally.

JNDI works fine at my local development environment, but when I run it at Godaddy, I get the following exception message:

Cannot create JDBC driver of class '' for connect URL 'null'

I have placed everything correctly in Godaddy server as in my local system.

Here is the context.xml

<?xml version="1.0" encoding="UTF-8"?>
<Context>
<!-- Specify a JDBC datasource -->

        <Resource
    name="jdbc/interviewzone"
    auth="Container"
    type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/interviewzone">
    <parameter>
        <name>factory</name>
        <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
    </parameter>
    <parameter>
        <name>driverClassName</name>
        <value>com.mysql.jdbc.Driver</value>
    </parameter>
    <parameter>
        <name>url</name>
        <value>someurl</value>
    </parameter>
    <parameter>
        <name>username</name>
        <value>root</value>
    </parameter>
    <parameter>
        <name>password</name>
        <value>root</value>
    </parameter>
    <parameter>
        <name>maxActive</name>
        <value>20</value>
    </parameter>
    <parameter>
        <name>maxIdle</name>
        <value>10</value>
    </parameter>
    <parameter>
        <name>maxWait</name>
        <value>-1</value>
    </parameter>
    <parameter>
        <name>removeAbandoned</name>
        <value>true</value>
    </parameter>
    <parameter>
        <name>removeAbandonedTimeout</name>
        <value>300</value>
    </parameter>
    <parameter>
        <name>logAbandoned</name>
        <value>true</value>
    </parameter>
</ResourceParams>
</Context>

Here is the relevant part of my Java code:

Context initContext = new InitialContext();
DataSource dataSource = (DataSource) initContext.lookup("java:/comp/env/jdbc/interviewzone");
Connection conn = dataSource.getConnection(); // This throws exception.

I have included the resources in web.xml. Because it runs locally fine, I think that there is no problem in the code. I have contacted Godaddy, but they are technically weak. They told that the problem is in my code, but I don't agree with them because it is running locally fine.

A: 

You need to make sure that jar file containing the driver class that you need (com.mysql.jdbc.Driver) is in your WEB-INF/lib folder.

How are you deploying it to Godaddy?

ferrari fan
thanq for ur reply.....the mysql.jar file is already in lib folder......oneday i have tried without lib foder bcz i think godaddy people have placed the jar file in common folder....on anotherday i have tried by placing in the lib folder....in both cases i got same error.....
MAHESH
On your context.xml you have this URL jdbc:mysql://localhost:3306/interviewzone, is this what's being used on the godaddy side?
ferrari fan
i have used different url...but for security purpose i have posted here that url....with same url,userid and password i able to connect directly from jsp in godaddy.....but if i use jndi connectivity its showing exception
MAHESH