Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sql-server-2005/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
JPA-没有针对MSAccess数据库的EntityManager的持久性提供程序_Jpa_Ms Access 2007 - Fatal编程技术网

JPA-没有针对MSAccess数据库的EntityManager的持久性提供程序

JPA-没有针对MSAccess数据库的EntityManager的持久性提供程序,jpa,ms-access-2007,Jpa,Ms Access 2007,我试图使用JPA通过JDBC:ODBC连接连接到MS access数据库。以下是我的persistence.xml代码: <?xml version="1.0" encoding="UTF-8"?> <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLoc

我试图使用JPA通过JDBC:ODBC连接连接到MS access数据库。以下是我的persistence.xml代码:

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.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_1_0.xsd">
    <persistence-unit name="DSRJPA">
    <provider>oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider</provider>
    <class>com.entity.AccessEntity</class>
    <properties>
    <property name="toplink.jdbc.url" value="jdbc:odbc:MSAccessDB"/>
    <property name="toplink.jdbc.user" value="admin"/>
    <property name="toplink.jdbc.driver" value="sun.jdbc.odbc.JdbcOdbcDriver"/>
    <property name="toplink.jdbc.password" value="admin"/>
    <property name="toplink.jdbc.read-connections.min" value="1"/>   
    <property name="toplink.jdbc.write-connections.min" value="1"/> 
    </properties>
    </persistence-unit>
</persistence>
请给我解释一下这个错误。
提前谢谢。

你在课堂上提到过你的持久性单元吗

i、 e


你确定你的persistence.xml被选中了吗?它的命名是否正确,是否放置在META-INF文件夹中,而META-INF文件夹又位于类路径的根目录中(直接位于jar文件或/WEB-INF/classes/中,如果它是war文件)?确实,它看起来JPA找不到持久化单元。您的文件名是Persistence.xml还是Persistence.xml(是否有输入错误?)文件名及其位置是/DSRJPA/src/META-INF/Persistence.xml。它在正确的文件夹结构下存在,但我在运行它时继续得到错误。注意:我在IBMRAD7.5中使用JPA项目类型。
Exception in thread "main" javax.persistence.PersistenceException: No Persistence provider for EntityManager named DSRJPA:  The following providers:
oracle.toplink.essentials.PersistenceProvider
oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider
Returned null to createEntityManagerFactory.

    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:154)
    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:83)
    at com.test.Access.main(Access.java:19)
EntityManagerFactory emf = Persistence.createEntityManagerFactory("DSRJPA");