ConnectionProviderFactory.getConnectionProperties() includes extra properties

Description

In our environment we are setting a number of properties with keys like 'rpt.3.hibernate.connection.url'. They are used indirectly for configuring hibernate, but only a small fraction of them are used for configuring any given hibernate session. Unfortunately, all these System properties are being pulled into JDBC URL because of ConnectionProviderFactory, which causes problems like this with DerbyDB:

2009-11-13 09:57:19,065 [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1] WARN com.mchange.v2.resourcepool.BasicResourcePool - com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@67f2b0dd – Acquisition Attempt Failed!!! Clearing pending acquires. While trying to acquire a needed new resource, we failed to succeed more than the maximum number of allowed acquisition attempts (30). Last acquisition attempt exception:
java.sql.SQLTransientConnectionException: A connection could not be established because the database name 'reports/lisa-reports.db;ction.password_enc=76f271db3661fd50082e68d4b953fbee;ction.username=sa;autocommit=false;ion.url=internal;create=true;ction.url=jdbc:derby://localhost:1527/db/reports.db;ction.driver_class=org.apache.derby.jdbc.ClientDriver' is larger than the maximum length allowed by the network protocol.
at org.apache.derby.client.am.SQLExceptionFactory40.getSQLException(Unknown Source)
at org.apache.derby.client.am.SqlException.getSQLException(Unknown Source)
at org.apache.derby.jdbc.ClientDriver.connect(Unknown Source)
at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:134)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:182)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:171)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:137)
at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1014)
at com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:32)
at com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1810)
at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)
Caused by: org.apache.derby.client.am.SqlException: A connection could not be established because the database name 'reports/lisa-reports.db;ction.password_enc=76f271db3661fd50082e68d4b953fbee;ction.username=sa;autocommit=false;ion.url=internal;create=true;ction.url=jdbc:derby://localhost:1527/db/reports.db;ction.driver_class=org.apache.derby.jdbc.ClientDriver' is larger than the maximum length allowed by the network protocol.
at org.apache.derby.client.net.NetConnectionRequest.buildRDBNAM(Unknown Source)
at org.apache.derby.client.net.NetConnectionRequest.buildACCSEC(Unknown Source)
at org.apache.derby.client.net.NetConnectionRequest.writeAccessSecurity(Unknown Source)
at org.apache.derby.client.net.NetConnection.writeServerAttributesAndKeyExchange(Unknown Source)
at org.apache.derby.client.net.NetConnection.flowServerAttributesAndKeyExchange(Unknown Source)
at org.apache.derby.client.net.NetConnection.flowUSRIDPWDconnect(Unknown Source)
at org.apache.derby.client.net.NetConnection.flowConnect(Unknown Source)
at org.apache.derby.client.net.NetConnection.<init>(Unknown Source)
at org.apache.derby.client.net.NetConnection40.<init>(Unknown Source)
at org.apache.derby.client.net.ClientJDBCObjectFactoryImpl40.newNetConnection(Unknown Source)
... 9 more

Attached is a test case and patch.

Environment

Hibernate 3.2.4.sp1, Derby DB.
Any Java environment where System properties include many properties whose names include 'hibernate.connection' but do not start with 'hibernate.connection'.

Activity

Show:
Strong Liu
December 24, 2009, 3:41 PM

patch applied

Steve Ebersole
March 21, 2011, 7:04 PM

Bulk closing stale resolved issues

Fixed

Assignee

Strong Liu

Reporter

Kevin Bowman

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure