Eclipselink没有为jdbc:mysql找到合适的驱动程序

时间:2012-01-03 21:36:34

标签: java jsf eclipselink

错误

找不到适合jdbc的驱动程序:mysql:// localhost:3306 / mazedb

完整错误

INFO: [EL Info]: 2012-01-03
23:27:35.522--ServerSession(11375975)--EclipseLink, version: Eclipse
Persistence Services - 2.3.0.v20110604-r9504

INFO: [EL Severe]: 2012-01-03
23:27:35.528--ServerSession(11375975)--Local Exception Stack: 
Exception [EclipseLink-4002] (Eclipse Persistence Services -
2.3.0.v20110604-r9504): org.eclipse.persistence.exceptions.DatabaseException Internal
Exception: java.sql.SQLException: No suitable driver found for
jdbc:mysql://localhost:3306/mazedb Error Code: 0    at
org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:324)
    at
org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:319)
    at
org.eclipse.persistence.sessions.DefaultConnector.connect(DefaultConnector.java:138)
    at
org.eclipse.persistence.sessions.DatasourceLogin.connectToDatasource(DatasourceLogin.java:162)
    at
org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.loginAndDetectDatasource(DatabaseSessionImpl.java:582)
    at
org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:206)
    at
org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:472)
    at
org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getDatabaseSession(EntityManagerFactoryDelegate.java:188)
    at
org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.createEntityManagerImpl(EntityManagerFactoryDelegate.java:277)
    at
org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:290)
    at
org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:268)
    at
com.maze.service.AccountService.validateLogin(AccountService.java:18)
    at
com.maze.controller.AccountController.performLogin(AccountController.java:31)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)  at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)     at
com.sun.el.parser.AstValue.invoke(AstValue.java:234)    at
com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:297)
    at
com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
    at
javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
    at
com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
    at javax.faces.component.UICommand.broadcast(UICommand.java:315)    at
javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)
    at
javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259)
    at
com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)    at
com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)   at
org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1539)
    at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
    at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    at
org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
    at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
    at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)   at
com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)
    at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
    at
org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:330)
    at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
    at
com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:174)
    at
com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828)
    at
com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725)
    at
com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019)
    at
com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
    at
com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
    at
com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
    at
com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
    at
com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
    at
com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
    at
com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
    at com.sun.grizzly.ContextTask.run(ContextTask.java:71)     at
com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
    at
com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
    at java.lang.Thread.run(Thread.java:662) Caused by:
java.sql.SQLException: No suitable driver found for
jdbc:mysql://localhost:3306/mazedb  at
java.sql.DriverManager.getConnection(DriverManager.java:602)    at
java.sql.DriverManager.getConnection(DriverManager.java:154)    at
org.eclipse.persistence.sessions.DefaultConnector.connect(DefaultConnector.java:98)
    ... 51 more

WARNING: #{accountController.performLogin}:
javax.persistence.PersistenceException: Exception [EclipseLink-4002]
(Eclipse Persistence Services - 2.3.0.v20110604-r9504):
org.eclipse.persistence.exceptions.DatabaseException Internal
Exception: java.sql.SQLException: No suitable driver found for
jdbc:mysql://localhost:3306/mazedb Error Code: 0
javax.faces.FacesException: #{accountController.performLogin}:
javax.persistence.PersistenceException: Exception [EclipseLink-4002]
(Eclipse Persistence Services - 2.3.0.v20110604-r9504):
org.eclipse.persistence.exceptions.DatabaseException Internal
Exception: java.sql.SQLException: No suitable driver found for
jdbc:mysql://localhost:3306/mazedb Error Code: 0    at
com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:118)
    at javax.faces.component.UICommand.broadcast(UICommand.java:315)    at
javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)
    at
javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259)
    at
com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)    at
com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)   at
org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1539)
    at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
    at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    at
org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
    at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
    at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)   at
com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)
    at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
    at
org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:330)
    at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
    at
com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:174)
    at
com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828)
    at
com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725)
    at
com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019)
    at
com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
    at
com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
    at
com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
    at
com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
    at
com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
    at
com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
    at
com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
    at com.sun.grizzly.ContextTask.run(ContextTask.java:71)     at
com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
    at
com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
    at java.lang.Thread.run(Thread.java:662) Caused by:
javax.faces.el.EvaluationException:
javax.persistence.PersistenceException: Exception [EclipseLink-4002]
(Eclipse Persistence Services - 2.3.0.v20110604-r9504):
org.eclipse.persistence.exceptions.DatabaseException Internal
Exception: java.sql.SQLException: No suitable driver found for
jdbc:mysql://localhost:3306/mazedb Error Code: 0    at
javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:102)
    at
com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
    ... 32 more Caused by: javax.persistence.PersistenceException:
Exception [EclipseLink-4002] (Eclipse Persistence Services -
2.3.0.v20110604-r9504): org.eclipse.persistence.exceptions.DatabaseException Internal
Exception: java.sql.SQLException: No suitable driver found for
jdbc:mysql://localhost:3306/mazedb Error Code: 0    at
org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:501)
    at
org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getDatabaseSession(EntityManagerFactoryDelegate.java:188)
    at
org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.createEntityManagerImpl(EntityManagerFactoryDelegate.java:277)
    at
org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:290)
    at
org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:268)
    at
com.maze.service.AccountService.validateLogin(AccountService.java:18)
    at
com.maze.controller.AccountController.performLogin(AccountController.java:31)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)  at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)     at
com.sun.el.parser.AstValue.invoke(AstValue.java:234)    at
com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:297)
    at
com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
    at
javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
    ... 33 more Caused by: Exception [EclipseLink-4002] (Eclipse
Persistence Services - 2.3.0.v20110604-r9504):
org.eclipse.persistence.exceptions.DatabaseException Internal
Exception: java.sql.SQLException: No suitable driver found for
jdbc:mysql://localhost:3306/mazedb Error Code: 0    at
org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:324)
    at
org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:319)
    at
org.eclipse.persistence.sessions.DefaultConnector.connect(DefaultConnector.java:138)
    at
org.eclipse.persistence.sessions.DatasourceLogin.connectToDatasource(DatasourceLogin.java:162)
    at
org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.loginAndDetectDatasource(DatabaseSessionImpl.java:582)
    at
org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:206)
    at
org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:472)
    ... 47 more Caused by: java.sql.SQLException: No suitable driver
found for jdbc:mysql://localhost:3306/mazedb    at
java.sql.DriverManager.getConnection(DriverManager.java:602)    at
java.sql.DriverManager.getConnection(DriverManager.java:154)    at
org.eclipse.persistence.sessions.DefaultConnector.connect(DefaultConnector.java:98)
    ... 51 more

INFO: Exit : invoke_application 5 WARNING: StandardWrapperValve[Faces
Servlet]: PWC1406: Servlet.service() for servlet Faces Servlet threw
exception javax.faces.el.EvaluationException:
javax.persistence.PersistenceException: Exception [EclipseLink-4002]
(Eclipse Persistence Services - 2.3.0.v20110604-r9504):
org.eclipse.persistence.exceptions.DatabaseException Internal
Exception: java.sql.SQLException: No suitable driver found for
jdbc:mysql://localhost:3306/mazedb Error Code: 0    at
javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:102)
    at
com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
    at javax.faces.component.UICommand.broadcast(UICommand.java:315)    at
javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)
    at
javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259)
    at
com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)    at
com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)   at
org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1539)
    at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
    at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    at
org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
    at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
    at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)   at
com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)
    at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
    at
org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:330)
    at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
    at
com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:174)
    at
com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828)
    at
com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725)
    at
com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019)
    at
com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
    at
com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
    at
com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
    at
com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
    at
com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
    at
com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
    at
com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
    at com.sun.grizzly.ContextTask.run(ContextTask.java:71)     at
com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
    at
com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
    at java.lang.Thread.run(Thread.java:662) Caused by:
javax.persistence.PersistenceException: Exception [EclipseLink-4002]
(Eclipse Persistence Services - 2.3.0.v20110604-r9504):
org.eclipse.persistence.exceptions.DatabaseException Internal
Exception: java.sql.SQLException: No suitable driver found for
jdbc:mysql://localhost:3306/mazedb Error Code: 0    at
org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:501)
    at
org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getDatabaseSession(EntityManagerFactoryDelegate.java:188)
    at
org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.createEntityManagerImpl(EntityManagerFactoryDelegate.java:277)
    at
org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:290)
    at
org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:268)
    at
com.maze.service.AccountService.validateLogin(AccountService.java:18)
    at
com.maze.controller.AccountController.performLogin(AccountController.java:31)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)  at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)     at
com.sun.el.parser.AstValue.invoke(AstValue.java:234)    at
com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:297)
    at
com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
    at
javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
    ... 33 more Caused by: Exception [EclipseLink-4002] (Eclipse
Persistence Services - 2.3.0.v20110604-r9504):
org.eclipse.persistence.exceptions.DatabaseException Internal
Exception: java.sql.SQLException: No suitable driver found for
jdbc:mysql://localhost:3306/mazedb Error Code: 0    at
org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:324)
    at
org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:319)
    at
org.eclipse.persistence.sessions.DefaultConnector.connect(DefaultConnector.java:138)
    at
org.eclipse.persistence.sessions.DatasourceLogin.connectToDatasource(DatasourceLogin.java:162)
    at
org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.loginAndDetectDatasource(DatabaseSessionImpl.java:582)
    at
org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:206)
    at
org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:472)
    ... 47 more Caused by: java.sql.SQLException: No suitable driver
found for jdbc:mysql://localhost:3306/mazedb    at
java.sql.DriverManager.getConnection(DriverManager.java:602)    at
java.sql.DriverManager.getConnection(DriverManager.java:154)    at
org.eclipse.persistence.sessions.DefaultConnector.connect(DefaultConnector.java:98)
    ... 51 more

的persistence.xml

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
        xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">

    <persistence-unit name="Maze" transaction-type="RESOURCE_LOCAL">
        <properties>
            <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/mazedb"/>
            <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>
            <property name="javax.persistence.jdbc.user" value="maze"/>
            <property name="javax.persistence.jdbc.password" value="maze"/>
        </properties>

    </persistence-unit>
</persistence>

mysql连接器包含在构建路径

2 个答案:

答案 0 :(得分:3)

  

找不到适合jdbc的驱动程序:mysql:// localhost:3306 / mazedb

此异常基本上有两种可能的原因。

  1. JDBC URL错误(基本上,Driver#acceptsURL()已为所有加载到目前为止的JDBC驱动程序返回false
  2. 根本没有加载JDBC驱动程序(因此它在运行时类路径中丢失,或者JDBC驱动程序类名中存在拼写错误)。
  3. 到目前为止,JDBC URL和驱动程序类名称看起来正确。所以驱动程序根本不在运行时类路径中。


      

    mysql连接器包含在构建路径

    JDBC驱动程序需要存在于webapp的运行时类路径中。如果是本地持久性单元,则需要将JDBC驱动程序JAR文件放在/WEB-INF/lib文件夹中。

    此异常表明情况并非如此。将JAR文件放在某个随机位置并手动将文件添加到构建路径而不在部署程序集中指定它可能会导致此异常。这个不对。只需将JAR文件放在/WEB-INF/lib文件夹中,这样Eclipse就可以完成所有必要的操作,无需触摸项目属性中的任何内容。


    对具体问题

    无关,考虑容器管理的事务(将事务类型设置为JTA而不是资源本地)。它将大大减少EJB中的样板代码以管理事务。您只需要创建容器管理的JNDI数据源,并将JDBC驱动程序放在服务器的/lib中。

答案 1 :(得分:1)

这是在服务器上运行吗?你的项目中有mysql数据库驱动程序jar文件吗?

以下是我的驱动程序设置在eclipse中的样子。您将通过数据库透视图进入此屏幕并添加新数据源。您包含驱动程序jar文件,以便它知道在哪里可以找到驱动程序。如果这是在服务器上,请将jar文件放在lib或deploy文件夹中,以便找到驱动程序。

Mysql setup in eclipse