当前位置: 技术问答>java相关
再问JSP+MySQL数据库连接问题!
来源: 互联网 发布时间:2015-10-28
本文导语: jsp连接mysql数据库时,设置如下: 环境变量CLASSPATH=d:j2sdk1.4.0libtools.jar;d:tomcatjakarta-tomcat-3.3.1classes;d:tomcatjakarta-tomcat-3.3.1lib 在d:tomcatjakarta-tomcat-3.3.1lib下有jdbc驱动程序mm.mysql-2.0.4-bin.jar 每次按照以下方法连接数据库时...
jsp连接mysql数据库时,设置如下:
环境变量CLASSPATH=d:j2sdk1.4.0libtools.jar;d:tomcatjakarta-tomcat-3.3.1classes;d:tomcatjakarta-tomcat-3.3.1lib
在d:tomcatjakarta-tomcat-3.3.1lib下有jdbc驱动程序mm.mysql-2.0.4-bin.jar
每次按照以下方法连接数据库时,
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
出错,在csdn上搜索相关贴子也没能解决问题,请教高手,该如何设置?
谢谢!
错误信息为:
Error: 500
Location: /conndb.jsp
Internal Servlet Error:
javax.servlet.ServletException: org.gjt.mm.mysql.Driver
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:460)
at conndb_4._jspService(conndb_4.java:257)
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:574)
at org.apache.tomcat.core.Handler.invoke(Handler.java:322)
at org.apache.tomcat.core.Handler.service(Handler.java:235)
at org.apache.tomcat.facade.ServletHandler.service(ServletHandler.java:485)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:917)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:833)
at org.apache.tomcat.modules.server.Http10Interceptor.processConnection(Http10Interceptor.java:176)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:494)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:516)
at java.lang.Thread.run(Thread.java:536)
Root cause:
java.lang.ClassNotFoundException: org.gjt.mm.mysql.Driver
at org.apache.tomcat.util.depend.DependClassLoader.loadClassInternal1(DependClassLoader.java:186)
at org.apache.tomcat.util.depend.DependClassLoader12$1.run(DependClassLoader12.java:92)
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.tomcat.util.depend.DependClassLoader12.loadClass(DependClassLoader12.java:90)
at java.lang.ClassLoader.loadClass(ClassLoader.java:262)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:322)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:130)
at conndb_4._jspService(conndb_4.java:100)
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:574)
at org.apache.tomcat.core.Handler.invoke(Handler.java:322)
at org.apache.tomcat.core.Handler.service(Handler.java:235)
at org.apache.tomcat.facade.ServletHandler.service(ServletHandler.java:485)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:917)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:833)
at org.apache.tomcat.modules.server.Http10Interceptor.processConnection(Http10Interceptor.java:176)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:494)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:516)
at java.lang.Thread.run(Thread.java:536)
环境变量CLASSPATH=d:j2sdk1.4.0libtools.jar;d:tomcatjakarta-tomcat-3.3.1classes;d:tomcatjakarta-tomcat-3.3.1lib
在d:tomcatjakarta-tomcat-3.3.1lib下有jdbc驱动程序mm.mysql-2.0.4-bin.jar
每次按照以下方法连接数据库时,
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
出错,在csdn上搜索相关贴子也没能解决问题,请教高手,该如何设置?
谢谢!
错误信息为:
Error: 500
Location: /conndb.jsp
Internal Servlet Error:
javax.servlet.ServletException: org.gjt.mm.mysql.Driver
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:460)
at conndb_4._jspService(conndb_4.java:257)
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:574)
at org.apache.tomcat.core.Handler.invoke(Handler.java:322)
at org.apache.tomcat.core.Handler.service(Handler.java:235)
at org.apache.tomcat.facade.ServletHandler.service(ServletHandler.java:485)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:917)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:833)
at org.apache.tomcat.modules.server.Http10Interceptor.processConnection(Http10Interceptor.java:176)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:494)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:516)
at java.lang.Thread.run(Thread.java:536)
Root cause:
java.lang.ClassNotFoundException: org.gjt.mm.mysql.Driver
at org.apache.tomcat.util.depend.DependClassLoader.loadClassInternal1(DependClassLoader.java:186)
at org.apache.tomcat.util.depend.DependClassLoader12$1.run(DependClassLoader12.java:92)
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.tomcat.util.depend.DependClassLoader12.loadClass(DependClassLoader12.java:90)
at java.lang.ClassLoader.loadClass(ClassLoader.java:262)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:322)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:130)
at conndb_4._jspService(conndb_4.java:100)
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:574)
at org.apache.tomcat.core.Handler.invoke(Handler.java:322)
at org.apache.tomcat.core.Handler.service(Handler.java:235)
at org.apache.tomcat.facade.ServletHandler.service(ServletHandler.java:485)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:917)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:833)
at org.apache.tomcat.modules.server.Http10Interceptor.processConnection(Http10Interceptor.java:176)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:494)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:516)
at java.lang.Thread.run(Thread.java:536)
|
或者放在d:j2sdk1.4.0jrelibext下