You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Gary Gregory (JIRA)" <ji...@apache.org> on 2019/01/15 08:53:00 UTC

[jira] [Commented] (DBCP-535) SharedPoolDataSource does not sent connectionProperties to the JDBC driver

    [ https://issues.apache.org/jira/browse/DBCP-535?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16742879#comment-16742879 ] 

Gary Gregory commented on DBCP-535:
-----------------------------------

Feel free to provide a patch on GitHub with a unit test p ;-)

> SharedPoolDataSource does not sent connectionProperties to the JDBC driver
> --------------------------------------------------------------------------
>
>                 Key: DBCP-535
>                 URL: https://issues.apache.org/jira/browse/DBCP-535
>             Project: Commons DBCP
>          Issue Type: Bug
>    Affects Versions: 2.5.0
>         Environment: Windows 10 / Java 11
>            Reporter: Michael Seele
>            Priority: Major
>
> We are using org.apache.commons.dbcp2.datasources.SharedPoolDataSource via JNDI and need to send special *connectionProperties* to our *Oracle JDBC Driver*. Unfortunaly that does not work. 
> Here is an example based on your [JNDI Howto|https://commons.apache.org/proper/commons-dbcp/guide/jndi-howto.html]:
> {{InitialContext ic = new InitialContext();}}
> {{// Construct DriverAdapterCPDS reference}}
>  {{Reference cpdsRef = new Reference("org.apache.commons.dbcp2.cpdsadapter.DriverAdapterCPDS",}}
>  {{"org.apache.commons.dbcp2.cpdsadapter.DriverAdapterCPDS", null);}}
>  {{cpdsRef.add(new StringRefAddr("driver", "oracle.jdbc.OracleDriver"));}}
>  {{cpdsRef.add(new StringRefAddr("url", "jdbc:oracle:thin:@server:port:sid"));}}
>  {{cpdsRef.add(new StringRefAddr("user", "foo"));}}
>  {{cpdsRef.add(new StringRefAddr("password", "bar"));}}
>  {{ic.rebind("jdbc/cpds", cpdsRef);}}
> {{// Construct SharedPoolDataSource reference}}
>  {{Reference ref = new Reference("org.apache.commons.dbcp2.datasources.SharedPoolDataSource",}}
>  {{"org.apache.commons.dbcp2.datasources.SharedPoolDataSourceFactory", null);}}
>  {{ref.add(new StringRefAddr("dataSourceName", "jdbc/cpds"));}}
>  {{ref.add(new StringRefAddr("defaultMaxTotal", "100"));}}
>  {{ref.add(new StringRefAddr("defaultMaxIdle", "30"));}}
>  {{ref.add(new StringRefAddr("defaultMaxWaitMillis", "10000"));}}
> *{{// the connection properties we need to set}}*
> *{{ref.add(new StringRefAddr("connectionProperties", "defaultRowPrefetch=100"));}}*
> {{ic.rebind("jdbc/shared", ref);}}
> {{// Use}}
>  {{InitialContext ic2 = new InitialContext();}}
>  {{DataSource ds = (DataSource) ic2.lookup("jdbc/shared");}}
>  {{assertNotNull(ds);}}
>  {{Connection conn = ds.getConnection("foo","bar");}}
>  {{assertNotNull(conn);}}
>  {{conn.close();}}
>  
> Normally the defaultRowPrefetch in the oracle driver should be 100 but it's still the default value (10).
> The same happens when we use *PerUserPoolDataSource* instead of *SharedPoolDataSource*.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)