So definieren Sie einen non-JTA-datasource für JPA-Hibernate? org.hibernate.- Verbindung.DatasourceConnectionProvider - Konnte nicht finden, Datenquelle:

Ich versuche zu ändern meine web-app-JDBC-code zu JPA mit Hibernate als provider. Ich bin mit der Eclipse IDE. In diesem ich habe eine MySQL-Datenquelle. Ich habe es in der persistence.xml.
Aber, ich erhalte die folgende Fehlermeldung.

6640 [30289364@qtp-7494106-7] ERROR org.hibernate.connection.DatasourceConnectionProvider  - Could not find datasource: tamSql
javax.naming.NameNotFoundException; remaining name 'tamSql'

Meine persistence.xml sieht so aus,

<?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="ExpensePersistentUnit" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<non-jta-data-source>tamSql</non-jta-data-source>
    <class>com.pricar.JPAInteg.Role</class>
    <class>com.pricar.JPAInteg.User</class>
    <class>com.pricar.JPAInteg.Userdetail</class>
    <class>com.pricar.JPAInteg.Category</class>
    <class>com.pricar.JPAInteg.Expens</class>
    <class>com.pricar.JPAInteg.Leavetable</class>
    <class>com.pricar.JPAInteg.Permissiontoken</class>
    <class>com.pricar.JPAInteg.Roletokenassociation</class>
    <class>com.pricar.JPAInteg.UserPK</class>
<properties>
    <property name="hibernate.connection.url" value="jdbc:mysql://localhost/officemgmt"/>
    <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"></property>
    <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
    <property name="hibernate.connection.password" value="1234"/>
    <property name="hibernate.connection.username" value="root"/>
    <property name="hibernate.hbm2ddl.auto" value="update"/>
    <property name="hibernate.show_sql" value="true"/>

</properties>

Anregungen!!!
Vielen Dank im Voraus!

  • Können Sie nach dem code, wie Sie deklariert den JNDI-Namen.
  • Können Sie mir sagen, was ist JNDI-name & wo ich es zu erklären. Ich bin sehr sehr neu in JPA & Hibernate. Dank
InformationsquelleAutor | 2010-09-20
Schreibe einen Kommentar