急急,急得不可开交,jsp如何连接数据库???

willzzq 2002-02-05 07:37:21
给50分,请教大虾
原码如下(d.jsp):
<%@ page contentType="text/html;charset=gb2312" %>
<%
java.sql.Connection conn;
java.lang.String strConn;
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
conn= java.sql.DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","");
%>

结果是一大堆错误!我的配置都检查过好几遍啦。苦恼:(


Error: 500
Location: /d.jsp
Internal Servlet Error:

javax.servlet.ServletException: org.gjt.mm.mysql.Driver
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:455)
at d_3._jspService(d_3.java:62)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
at javax.servlet.http.HttpServlet.service(HttpServlet.java)
at org.apache.tomcat.facade.ServletHandler.doService(ServletHandler.java:500)
at org.apache.tomcat.core.Handler.service(Handler.java:223)
at org.apache.tomcat.facade.ServletHandler.service(ServletHandler.java:448)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:911)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:824)
at org.apache.tomcat.modules.server.Http10Interceptor.processConnection(Http10Interceptor.java:152)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:438)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:505)
at java.lang.Thread.run(Thread.java:484)
Root cause:
java.lang.ClassNotFoundException: org.gjt.mm.mysql.Driver
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
at java.net.FactoryURLClassLoader.loadClass(URLClassLoader.java:553)
at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:120)
at d_3._jspService(d_3.java:55)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
at javax.servlet.http.HttpServlet.service(HttpServlet.java)
at org.apache.tomcat.facade.ServletHandler.doService(ServletHandler.java:500)
at org.apache.tomcat.core.Handler.service(Handler.java:223)
at org.apache.tomcat.facade.ServletHandler.service(ServletHandler.java:448)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:911)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:824)
at org.apache.tomcat.modules.server.Http10Interceptor.processConnection(Http10Interceptor.java:152)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:438)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:505)
at java.lang.Thread.run(Thread.java:484)


...全文
106 点赞 收藏 5
写回复
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
zijianyi 2002-02-06
这个不大知道了我用win2000+resin+jdk1.3是这样的

<%@ page language="java" import="java.sql.*" contentType="text/html;charset=gb2312"%>
<%
java.sql.Connection Conn;
java.sql.Statement Stmt;
java.sql.ResultSet Rst;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Conn=DriverManager.getConnection("jdbc:odbc:a");
Stmt=Conn.createStatement();
%>
回复
phil21 2002-02-05
关注
回复
hotspot 2002-02-05
mysql的JDBC驱动程序应该放到JVM的classpath中去
回复
wyy_9715072 2002-02-05
你有没有把mysql的jdbc类放到classes里边去?
回复
willzzq 2002-02-05
我的环境是
win2000: professional
tomcat: 3.3-b1
jdbc: mm.mysql.jdbc-1.2c
jdk: jdk1.3.1_02 for win32
mysql: mysql-3.23.47-win

请教请教请教请教请教请教
回复
发动态
发帖子
Web 开发
创建于2007-09-28

7.9w+

社区成员

Java Web 开发
申请成为版主
社区公告
暂无公告