问题描述
我正在尝试配置Sniffy以与Oracle合作。我使用Glassfish作为应用程序服务器,使用JPA 2.0,使用EclipseLink作为提供程序。
I'm trying to configure Sniffy to work with Oracle. I'm using Glassfish as application server, with JPA 2.0, and EclipseLink as provider.
当EclipseLink尝试分配连接时,它无法说明指定的Oracle URL是无效,因为sniffer:
前缀,我想:
When EclipseLink tries to allocate the connection, it fails saying that the Oracle URL specified is invalid, because of the "sniffer:"
prefix, I guess:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jpaMappingContext': Invocation of init method failed;
nested exception is javax.persistence.PersistenceException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.1.v20130918-f2b9fc5): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: Error in allocating a connection. Cause: Connection could not be allocated because: Invalid Oracle URL specified
Error Code: 0
这是我在domain.xml文件中配置池的方式:
This is how I configured the pool in my domain.xml file:
<jdbc-resource pool-name="poolGI" object-type="system-all" jndi-name="jdbc/poolGI" />
<jdbc-connection-pool driver-classname="io.sniffy.MockDriver" name="poolGI" res-type="javax.sql.DataSource" datasource-classname="oracle.jdbc.pool.OracleDataSource">
<property name="URL" value="sniffer:jdbc:oracle:thin:@(DESCRIPTION=(LOAD_BALANCE=on)(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=host1)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=host2)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=service)))"></property>
<property name="user" value="user"></property>
<property name="password" value="password"></property>
</jdbc-connection-pool>
推荐答案
开发人员。
看起来像 oracle.jdbc.pool.OracleDataSource
忽略 driver-classname
属性并隐式使用 oracle.jdbc.driver.OracleDriver
。 OracleDriver不知道 sniffer:
架构,因此异常。
Looks like oracle.jdbc.pool.OracleDataSource
ignores the driver-classname
property and implicitly uses oracle.jdbc.driver.OracleDriver
. OracleDriver doesn't know about sniffer:
schema, hence the exception.
您需要切换到另一个数据源为了使用Sniffy。
例如。
You need to switch to another data source in order to use Sniffy.For example Hikari Connection Pool.
这篇关于使用Sniffy指定的无效Oracle URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!