我发现在持久性单元中指定数据源名称或通过属性动态指定数据源的名称存在差异。
在持久性单元:
<persistence-unit name="myPU" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<non-jta-data-source>datasourceName</non-jta-data-source>
动态:
使用其中一个属性 props.put(PersistenceUnitProperties.CONNECTION_POOL_NON_JTA_DATA_SOURCE,&#34;了dataSourceName&#34 ;; props.put(PersistenceUnitProperties.NON_JTA_DATASOURCE,&#34;的datasourcename&#34)
在第一个中,一个效果很好,在第二个中,< 使用任何属性(正确的外观CONNECTION_POOL_NON_JTA_DATA_SOURCE?):
Exception [EclipseLink-4021] (Eclipse Persistence Services - 2.3.1.v20111018-r10243): 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
我希望在PersistenceUnit之外拥有DataSourceName .. ..