0

我正在研究项目(REST),我将休眠与 glassfish 一起使用。我尝试从数据库中获取数据列表,但出现此错误:

  javax.persistence.PersistenceException: Exception [EclipseLink-4021] (Eclipse Persistence                  Services - 2.0.1.v20100213-r6600): org.eclipse.persistence.exceptions.DatabaseException
Exception Description: Unable to acquire a connection from driver [null], user [null] and URL    [null].  Verify that you have set the expected driver class and URL.  Check your login, persistence.xml      or sessions.xml resource.  The jdbc.driver property should be set to a class that is compatible with    your database platform
note The full stack traces of the exception and its root causes are available in the GlassFish   Server Open Source Edition 3.0.1 logs.  

持久性.XML

    <?xml version="1.0" encoding="UTF-8" ?>
    <persistence 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_1_0.xsd"
    version="1.0">
    <persistence-unit name="manager1"
    transaction-type="RESOURCE_LOCAL">

    <properties>
        <property name="hibernate.show_sql" value="false" />
        <property name="hibernate.format_sql" value="false" />
        <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver" />
        <property name="hibernate.connection.url"
            value="jdbc:mysql://url" />
        <property name="hibernate.connection.username" value="admin" />
        <property name="hibernate.connection.password" value="admin" />
        <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
        <property name="hibernate.hbm2ddl.auto" value="create-update" />

更新:

与休眠的连接有效,因为我在控制台中对其进行了测试。Hibernate 是否可能需要另一个用于休眠的配置文件?感谢帮助 :)

4

0 回答 0