Godaddy JNDI问题---无法为连接URL''创建类''的JDBC驱动程序 [英] Godaddy JNDI Problem---Cannot create JDBC driver of class '' for connect URL 'null'

查看:140
本文介绍了Godaddy JNDI问题---无法为连接URL''创建类''的JDBC驱动程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Godaddy有一个网站,我使用JNDI来管理数据库连接。 Godaddy使用Tomcat 5.5.27和JDK 1.5。我也在本地使用相同的版本。

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在我的本地开发环境中工作正常,但是当我在Godaddy运行它时,我收到以下异常消息:

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'

我已将所有内容正确放置在Godaddy服务器中,就像在我的本地系统中一样。

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

这是 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>

以下是我的Java代码的相关部分:

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.

我已将资源包含在 web.xml 。因为它在本地运行良好,我认为代码中没有问题。我联系了Godaddy,但他们技术上很弱。他们告诉我问题是在我的代码中,但我不同意它们,因为它在本地运行正常。

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.

推荐答案

您需要确保包含所需驱动程序类的jar文件(com.mysql.jdbc.Driver)位于WEB-INF / lib文件夹中。

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.

如何你把它部署到Godaddy?

How are you deploying it to Godaddy?

这篇关于Godaddy JNDI问题---无法为连接URL''创建类''的JDBC驱动程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆