我正在使用JPA和Hibernate实现,我在websphere服务器中创建了一个数据源。我试图在我的JPA应用程序中访问此数据源。但是,当我尝试访问时,我得到以下异常。如果遇到这种情况,请帮帮我。感谢
org.hibernate.HibernateException:找不到数据源 引起: javax.naming.NameNotFoundException:在上下文“java:”中找不到名称comp / env / jdbc。
请查看以下详细信息: 数据源名称:pieportaldev_0 JNDI名称:pie / logDB 我的Persistance.xml是
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd“version =”1.0“>
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<!-- the JNDI data source -->
<jta-data-source>java:comp/env/jdbc/pieportaldev_0</jta-data-source>
<class>com.test.jpa.UserInfo</class>
<properties>
<!-- if this is true, hibernate will print (to stdout) the SQL it executes, so you can check it to ensure it's not doing anything crazy -->
<!-- <property name="hibernate.show_sql" value="true" /> -->
<property name="hibernate.format_sql" value="true" />
<!-- since most database servers have slightly different versions of the SQL, Hibernate needs you to choose a dialect so it knows the subtleties of talking
to that server -->
<property name="hibernate.dialect" value="org.hibernate.dialect.OracleDialect" />
<!-- this tell Hibernate to update the DDL when it starts, very useful for development, dangerous in production -->
<property name="hibernate.hbm2ddl.auto" value="update" />
</properties>