sur*_*nda 6 tomcat jpa connection-pooling oracle10g
我在context.xmlTomcat中有以下代码:
<Resource name="ds/OracleDS" auth="Container" type="javax.sql.DataSource"
maxActive="1" maxIdle="2" maxWait="2"
username="demo" password="demo"
driverClassName="oracle.jdbc.driver.OracleDriver"
url="jdbc:oracle:thin:@localhost:1521:orcl"/>
Run Code Online (Sandbox Code Playgroud)
我有这个代码web.xml:
<resource-ref>
<description>Oracle Datasource example</description>
<res-ref-name>ds/OracleDS</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
Run Code Online (Sandbox Code Playgroud)
我编写的代码persistence.xml如下:
<persistence-unit name="ReceivablesPU" transaction-type="RESOURCE_LOCAL">
<provider>oracle.toplink.essentials.PersistenceProvider</provider>
<non-jta-data-source>java:ds/OracleDS</non-jta-data-source>
Run Code Online (Sandbox Code Playgroud)
我不明白java:ds/OracleDS,<Resource name="ds/OracleDS",<res-ref-name>ds/OracleDS</res-ref-name>.错误是:
javax.persistence.PersistenceException: Exception [TOPLINK-7060] (Oracle TopLink Essentials - 2.0 (Build b40-rc (03/21/2007))): oracle.toplink.essentials.exceptions.ValidationException
Exception Description: Cannot acquire data source [java:ds/OracleDS].
Internal Exception: javax.naming.NamingException: This context must be accessed through a java: URL
Run Code Online (Sandbox Code Playgroud)
我在contex.xml中进行了更改:
<Resource name="OracleDS" auth="Container" type="javax.sql.DataSource"
maxActive="1" maxIdle="2" maxWait="2"
username="demo" password="demo"
driverClassName="oracle.jdbc.driver.OracleDriver"
url="jdbc:oracle:thin:@localhost:1521:orcl"/>
Run Code Online (Sandbox Code Playgroud)
我在 web.xml 中进行了更改:
<resource-ref>
<description>Oracle Datasource example</description>
<res-ref-name>OracleDS</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
Run Code Online (Sandbox Code Playgroud)
我改变了 persistence.xml
<persistence-unit name="ReceivablesPU" transaction-type="RESOURCE_LOCAL">
<provider>oracle.toplink.essentials.PersistenceProvider</provider>
<non-jta-data-source>java:comp/env/OracleDS</non-jta-data-source>
Run Code Online (Sandbox Code Playgroud)
然后我得到了输出......
| 归档时间: |
|
| 查看次数: |
1110 次 |
| 最近记录: |