X
xdrt81y
Unregistered / Unconfirmed
GUEST, unregistred user!
最近在研究关于数据库的问题,写了一个程序,但是老连不上数据库,头疼啊,找了一下午,也没成功连接上
在netbean
总提示:
信息: AdminServlet: Error is processing add : com.wrox.begjsp.ch23.football.DataException: Cannot create JDBC driver of class '' for connect URL 'null'
2006-10-21 22:09:30 org.apache.catalina.core.ApplicationContext log
信息: AdminServlet: Error processing roster list : com.wrox.begjsp.ch23.football.DataException: Cannot create JDBC driver of class '' for connect URL 'null'
数据库的设置写在一个tomcat上下文文件ch13.xml,内容如下:
<Contextdo
Base="G:/hhd/java/netbeans/testch13/ch13/web"
path="/ch13"<?xml version="1.0"
encoding="UTF-8"?>
reloadable="true"
>
<Resource name="jdbc/FootyDB"
type="javax.sql.DataSource"
auth="Container"
/>
<ResourceParams name="jdbc/FootyDB">
<parameter>
<name>username</name>
<value>footy</value>
</parameter>
<parameter>
<name>password</name>
<value>footy</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>com.mysql.jdbc.Driver</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:mysql://localhost:3306/footydb?autoReconnect=true</value>
</parameter>
</ResourceParams>
</Context>
web应用的目录是这样的
ch13/
src/
web/
WEB-INF/
lib/
ch13.xml的文件在ch13目录下
连接数据库的文件是:FootyJDBCHelper.java
package com.wrox.begjsp.ch23.football;
import java.sql.Connection;
import java.sql.SQLException;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;
/**
*
* @author Administrator
*/
public class FootyJDBCHelper {
private DataSource _dataSource;
/** Creates a new instance of FootyJDBCHelper */
public FootyJDBCHelper() throws NamingException{
Context context = new InitialContext();
Context applicationEnv = (Context)context.lookup("java:comp/env"
_dataSource = (DataSource)applicationEnv.lookup("jdbc/FootyDB"
}
public Connection getConnection() throws SQLException
{
return _dataSource.getConnection();
}
}
事情就是这样,按照参考书上应该是没问题,但是就是报错?
高手指点指点,急急急!!!!!
在netbean
总提示:
信息: AdminServlet: Error is processing add : com.wrox.begjsp.ch23.football.DataException: Cannot create JDBC driver of class '' for connect URL 'null'
2006-10-21 22:09:30 org.apache.catalina.core.ApplicationContext log
信息: AdminServlet: Error processing roster list : com.wrox.begjsp.ch23.football.DataException: Cannot create JDBC driver of class '' for connect URL 'null'
数据库的设置写在一个tomcat上下文文件ch13.xml,内容如下:
<Contextdo
Base="G:/hhd/java/netbeans/testch13/ch13/web"
path="/ch13"<?xml version="1.0"
encoding="UTF-8"?>
reloadable="true"
>
<Resource name="jdbc/FootyDB"
type="javax.sql.DataSource"
auth="Container"
/>
<ResourceParams name="jdbc/FootyDB">
<parameter>
<name>username</name>
<value>footy</value>
</parameter>
<parameter>
<name>password</name>
<value>footy</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>com.mysql.jdbc.Driver</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:mysql://localhost:3306/footydb?autoReconnect=true</value>
</parameter>
</ResourceParams>
</Context>
web应用的目录是这样的
ch13/
src/
web/
WEB-INF/
lib/
ch13.xml的文件在ch13目录下
连接数据库的文件是:FootyJDBCHelper.java
package com.wrox.begjsp.ch23.football;
import java.sql.Connection;
import java.sql.SQLException;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;
/**
*
* @author Administrator
*/
public class FootyJDBCHelper {
private DataSource _dataSource;
/** Creates a new instance of FootyJDBCHelper */
public FootyJDBCHelper() throws NamingException{
Context context = new InitialContext();
Context applicationEnv = (Context)context.lookup("java:comp/env"
_dataSource = (DataSource)applicationEnv.lookup("jdbc/FootyDB"
}
public Connection getConnection() throws SQLException
{
return _dataSource.getConnection();
}
}
事情就是这样,按照参考书上应该是没问题,但是就是报错?
高手指点指点,急急急!!!!!