当我尝试在服务器上运行我的应用程序时出现错误。我正在起诉eclipse和glass fish server 4。我制作了一个glassfish-resources.xml文件并将其放在WEB-INF目录中。当我尝试在服务器上运行时。我得到以下异常
Internal Exception: java.sql.SQLException: Error in allocating a connection. Cause:
Connection could not be allocated because: Invalid Oracle URL specified:
OracleDataSource.makeURL
Error Code: 0
at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:316)
at org.eclipse.persistence.sessions.JNDIConnector.connect(JNDIConnector.java:135)
at org.eclipse.persistence.sessions.DatasourceLogin.connectToDatasource(DatasourceLogin.java:162)
at org.eclipse.persistence.internal.databaseaccess.DatasourceAccessor.connectInternal(DatasourceAccessor.java:330)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.connectInternal(DatabaseAccessor.java:307)
.....
这是我的 glassfish-resources.xml 文件
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE resources PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1
Resource Definitions//EN" "http://glassfish.org/dtds/glassfish-resources_1_5.dtd">
<resources>
<jdbc-connection-pool name="java:app/myOracleConnectionPool"
res-type="javax.sql.ConnectionPoolDataSource"
datasource-classname="oracle.jdbc.pool.OracleConnectionPoolDataSource">
<property name="User" value="system" />
<property name="Port" value="1521" />
<property name="DatabaseName" value="XE" />
<property name="ServerName" value="127.0.0.1" />
<property name="Url" value="jdbc:oracle:thin:@127.0.0.1:1521:XE" />
<property name="URL" value="jdbc:oracle:thin:@127.0.0.1:1521:XE" />
<property name="Password" value="xxxx" />
</jdbc-connection-pool>
<jdbc-resource enabled="true"
jndi-name="java:app/jdbc/myOracleDatasource"
object-type="user"
pool-name="java:app/myOracleConnectionPool">
<description />
</jdbc-resource>
</resources>
这是我的 persistence.xml 文件
<persistence-unit name="chapter11PU" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>java:app/jdbc/myOracleDatasource</jta-data-source>
<properties>
<property name="eclipselink.target-database" value="Oracle"/>
<property name="javax.persistence.schema-generation-action" value="drop-and-create"/>
<property name="javax.persistence.schema-generation-target" value="scripts"/>
<property name="javax.persistence.ddl-create-script-target" value="createfoo.sql"/>
<property name="javax.persistence.ddl-drop-script-target" value="dropfoo.sql"/>
<property name="eclipselink.deploy-on-startup" value="true"/>
<property name="eclipselink.application-location" value="/tmp"/>
<!-- To log SQL queries -->
<property name="eclipselink.logging.level.sql" value="FINE"/>
<property name="eclipselink.logging.parameters" value="true"/>
<property name="eclipselink.logging.level" value="INFO"/>
</properties>
</persistence-unit>
我还将 ojdbc6.jar 放在 lib/ext 文件夹中。我正在使用 oracle 11g 第 2 版。为什么我收到无效的 url 错误?
我还检查了 SQL Developer 中的连接,它正在使用用户系统和我的密码工作。
谢谢