我正在为我的动态web项目使用eclipse。。
我需要为我的网站登录页。我在server.xml中给出了以下配置:
<Realm className="org.apache.catalina.realm.LockOutRealm">
<Realm className="org.apache.catalina.realm.JDBCRealm"
driverName="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://localhost/Chat?user=root&password=public"
userTable="users" userNameCol="user_name" userCredCol="password" />
</Realm>
我已经定好了 mysql-connector-java-8.0.12.jar
在 java build path/libraries
运行程序时,出现以下错误:
SEVERE: Exception opening database connection
java.sql.SQLException: com.mysql.jdbc.Driver
at org.apache.catalina.realm.JDBCRealm.open(JDBCRealm.java:644)
at org.apache.catalina.realm.JDBCRealm.startInternal(JDBCRealm.java:715)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.realm.CombinedRealm.startInternal(CombinedRealm.java:245)
at org.apache.catalina.realm.LockOutRealm.startInternal(LockOutRealm.java:115)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:937)
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:261)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:422)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:770)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.startup.Catalina.start(Catalina.java:682)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:350)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:492)
Caused by: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:471)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:588)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:315)
at org.apache.catalina.realm.JDBCRealm.open(JDBCRealm.java:640)
... 19 more
但最后服务器启动了…当我尝试从登录页登录时,这个错误再次显示。。
mysql版本是8.0.12
1条答案
按热度按时间slwdgvem1#
从您所说的来看,您的类路径中似乎缺少mysql驱动程序jar。
https://examples.javacodegeeks.com/java-basics/exceptions/java-lang-classnotfoundexception-how-to-solve-class-not-found-exception/
你能试着手动复制jar吗
<Webappdir>/web-inf/lib
?