Weblogic 已经建立了数据源,经过测试是可用的。我在ejb3.0的persistence.xml 文件中添加如下配置
<persistence-unit name="reviewService"
transaction-type="JTA">
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
<jta-data-source>jdbc/dfs</jta-data-source>
</properties>
</persistence-unit>
会报错,无法连接,请教各位大大,我的使用方法后置步骤不是不有问题
------解决方案--------------------
报什么错?
persinstence文件没看出什么错
<jta-data-source>jdbc/dfs</jta-data-source>
这个问件放在哪??
就是jdbc/dfs
看看:
------解决方案--------------------
org.apache.openjpa.persistence.ArgumentException: A JDBC Driver or DataSource class name must be specified in the ConnectionDriverName property.
錯誤提示還是揭示了持久化環節中JDBC Driver或者數據源沒有準備妥當
如果排除驅動的可能性的話,剩下最大的可能就是沒有找正數據源的位置(因為數據源測試是OK的),正如一樓所說。
對細節不是很瞭解,只是有一點不明,通過JNDI來查找的數據源爲什麽測試時只需要指明dfs
而persistence.xml配置中卻是jdbc/dfs
------解决方案--------------------
和persinstence文件是一级的,
那就怪了,
<xa-datasource>
<jndi-name>jdbc/dfs</jndi-name>
<use-java-context>false</use-java-context>
<xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
<xa-datasource-property name="URL">jdbc:mysql://xxx</xa-datasource-property>
<xa-datasource-property name="User">root</xa-datasource-property>
<xa-datasource-property name="Password">123456</xa-datasource-property>
<track-connection-by-tx>true</track-connection-by-tx>
<isSameRM-override-value>false</isSameRM-override-value>
<no-tx-separate-pools />
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</exception-sorter-class-name>
<metadata>
<type-mapping>mySQL</type-mapping>
</metadata>
</xa-datasource>
数据源是这样的吗
------解决方案--------------------
<openjpa-1.1.0-r422266:657916 fatal user error> org.apache.openjpa.persistence.ArgumentException: A JDBC Driver or DataSource class name must be specified in the ConnectionDriverName property.
- XML code
<jdbc-driver-params> <url>jdbc:timesten:direct:tt</url> <driver-name>com.timesten.jdbc.TimesTenDriver</driver-name> <password-encrypted>{3DES}+ApzSbVeRNM=</password-encrypted> </jdbc-driver-params>
------解决方案--------------------
persistence.xml 和 数据源 都是在meta下的话
<persistence-unit name="reviewService"
transaction-type="JTA">
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
<jta-data-source>jdbc/dfs</jta-data-source>
</properties>
</persistence-unit>
这个,就用jndl 名字,
<jta-data-source>dfs</jta-data-source>
你的jndi 是dts;
<jdbc-data-source-params>
<jndi-name>dfs</jndi-name>
<global-transactions-protocol>OnePhaseCommit</global-transactions-protocol>
</jdbc-data-source-params>
------解决方案--------------------
Context initCtx = new InitialContext();
Context ctx = (Context) initCtx.lookup("java:comp/env");
Object obj = (Object)ctx.lookup("dfs");
linkdb = (javax.sql.DataSource) obj;