Hibernate Access数据源导致传递了异常Null UserID,无法创建连接
我已经在这个问题上工作了好几天了,还没有解决。我希望把我的问题贴在这里能指引我正确的方向。我浏览了许多论坛,所有论坛都说明了我遵循的相同步骤(如下所述),但我在访问数据源时仍然遇到相同的运行时异常Hibernate Access数据源导致传递了异常Null UserID,无法创建连接,hibernate,jpa,nullpointerexception,datasource,websphere-7,Hibernate,Jpa,Nullpointerexception,Datasource,Websphere 7,我已经在这个问题上工作了好几天了,还没有解决。我希望把我的问题贴在这里能指引我正确的方向。我浏览了许多论坛,所有论坛都说明了我遵循的相同步骤(如下所述),但我在访问数据源时仍然遇到相同的运行时异常 Exception - org.hibernate.exception.SQLGrammarException: Could not open connection at org.hibernate.exception.internal.SQLStateConversionDelegate.conv
Exception -
org.hibernate.exception.SQLGrammarException: Could not open connection
at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:122)
at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:49)
Caused by: java.sql.SQLNonTransientException: [jcc][t4][10205][11234][4.11.88] Null userid is not supported. ERRORCODE=-4461, SQLSTATE=42815 DSRA0010E: SQL-Status = 42815, Fehlercode = -4'461
at com.ibm.db2.jcc.am.gd.a(gd.java:676)
环境-Hibernate、JPA2.0、DB2、WebSphere8.0、RAD、JavaEE6部署网
resource-ref
res-ref-name Sample
res-type javax.sql.DataSource
res-auth Container
res-sharing-scope Shareable
resource-ref
resource-ref name="jdbc/Sample" binding-name="java:comp/env/jdbc/Sample"
persistence-unit name="samplePool" transaction-type="JTA"
provider org.hibernate.ejb.HibernatePersistence
jta-data-source jdbc/Sample
properties
property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.WebSphereExtendedJTATransactionLookup"
property name="hibernate.dialect" value="org.hibernate.dialect.DB2390Dialect"
properties
persistence-unit
persistence
eMgrFactory = Persistence.createEntityManagerFactory("samplePool");
entityMgr = eMgrFactory.createEntityManager();
entityMgr.createNativeQuery();
请注意,通过管理控制台创建数据源后,我能够成功测试连接。另外请注意,如果我指定组件管理的身份验证,我可以通过代码访问。建议如何通过容器管理的身份验证进行访问。部署后,必须将数据源映射到应用程序
.今天,我能够为我的问题找到解决方案。整个问题最终证明是一个配置问题。很好,我能解决。 以下是我所做的更改
我为其他人发布了解决方案。我尝试了参考资料部分。这没有帮助。对我来说,部署描述符应该负责配置设置。欢迎提出进一步建议。你好,卡里安。 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" version="2.0" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd" persistence-unit name="dataPool" transaction-type="JTA" provider org.hibernate.ejb.HibernatePersistence provider jta-data-source java:comp/env/jdbc/ds jta-data-source shared-cache-mode ALL shared-cache-mode properties property name="hibernate.dialect" value="org.hibernate.dialect.DB2390Dialect" property name="hibernate.default_schema" value="A11" property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.WebSphereExtendedJTATransactionLookup" property name="hibernate.transaction.jta.platform" value="org.hibernate.service.jta.platform.internal.WebSphereExtendedJtaPlatform" property name="hibernate.temp.use_jdbc_metadata_defaults" value="false" properties persistence-unit persistence resource-ref res-ref-name jdbc/ds res-ref-name lookup-name ACTUAL DATASOURCE lookup-name res-type javax.sql.DataSource res-type res-auth Container res-auth res-sharing-scope Shareable res-sharing-scope resource-ref