我在tomcat容器编译时DOS中提示 java.lang.ClassNotFoundException
com.mysql.jdbc.Driver
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:372)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause
java.lang.NullPointerException
org.apache.jsp.first_jsp._jspService(first_jsp.java:98)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.
下面是数据库的连接代码
package com.netshop;
import java.sql.*;
public class OpenDB
{
String userName= "root ";
String userPassword= "123456 ";
private String driverName = "com.mysql.jdbc.Driver ";// "org.gjt.mm.mysql.Driver ";(两种加载驱动程序方式都不行)
private String url = "jdbc:mysql://localhost/netshop?useUnicode=true&characterEncoding=gb2312 ";
Connection dbConn;
public OpenDB()
{
}
public Connection getConnection()
{
try
{
Class.forName(driverName);
dbConn=DriverManager.getConnection(url,userName,userPassword);
}
catch(Exception ex)
{
System.out.println(ex.toString());
dbConn = null;
}
return dbConn;
}
}
MySQL 版本是5.0.21 不知道是不是驱动器的原因还是?如果是的话应该要哪个版本的驱动器,该在哪里存放驱动的什么文件呢? 麻烦武林高手 在这深夜能出手相助,小弟在此感激不尽!