Hibernate和Glassfish配置

时间:2013-01-10 18:15:49

标签: java hibernate rest configuration glassfish

我正在开发项目(REST),我在其中使用了带有glassfish的hibernate。我尝试从DB获取数据列表,但是我收到此错误:

  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.  

的persistence.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的连接有效,因为我在控制台中测试了它。 Hibernate是否可能需要另一个用于休眠的配置文件? 感谢您的帮助:)

0 个答案:

没有答案