Invalid Oracle URL specified with Sniffy

陌路散爱 提交于 2019-12-08 05:53:53

问题


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.

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

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>

回答1:


Sniffy developer here.

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.

You need to switch to another data source in order to use Sniffy. For example Hikari Connection Pool.



来源:https://stackoverflow.com/questions/38761584/invalid-oracle-url-specified-with-sniffy

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!