我正在尝试配置JPA Web应用程序以使用JBOSS AS 7.1和Oracle。这是persistence.xml文件:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0"
xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="dbcon" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:/jboss/datasources/OracleDS</jta-data-source>
<class>code.TestCon</class>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.OracleDialect"/>
</properties>
</persistence-unit>
</persistence>
我将此代码添加到standalone-full.xml:
<datasource jta="true" jndi-name="java:jboss/datasources/OracleDS" pool-name="OracleDS" enabled="true" use-java-context="true" use-ccm="true">
<connection-url>jdbc:oracle:thin:@localhost:1521:orcl5</connection-url>
<driver>oracle</driver>
<user-name>C##test</user-name>
<password>test</password>
</datasource>
<driver name="oracle" module="com.oracle.ojdbc6">
<driver-class>oracle.jdbc.OracleDriver</driver-class>
</driver>
我收到错误:
Caused by: java.sql.SQLException: Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
我还在modules / com / oracle / ojdbc6 / main文件夹中添加了odjbc6.jar文件和module.xml。 我想指出,作为标准Java项目的JPA应用程序可以正常运行。请告知可能出现的问题。