EJB3.0+Weblogic10G+ORACEL 数据源配置问题
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.
<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;
貌似這個測試是因為weblogic內部已經配置了JDBC Driver了是吧
Load the TimesTen driver
The TimesTen JDBC driver must be loaded before it is available for making connections with a TimesTen data store. The TimesTen JDBC driver is:
com.timesten.jdbc.TimesTenDriver
If you are using the DriverManager interface to connect to TimesTen, call the Class.forName() method to load the TimesTen JDBC driver. This method creates an instance of the TimesTen driver and registers it with the driver manager. If you are using the TimesTenDataSource interface, you are not required to call Class.forName().
To identify and load the TimesTen driver:
Class.forName("com.timesten.jdbc.TimesTenDriver");
Note:
If the TimesTen JDBC driver is not loaded, TimesTen returns an error when the application attempts to connect to a TimesTen data store.