[
https://issues.apache.org/jira/browse/DBCP-547?focusedWorklogId=271740&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-271740
]
ASF GitHub Bot logged work on DBCP-547:
---------------------------------------
Author: ASF GitHub Bot
Created on: 03/Jul/19 17:11
Start Date: 03/Jul/19 17:11
Worklog Time Spent: 10m
Work Description: garydgregory commented on pull request #33: [DBCP-547]
Add a ConnectionFactory interface in BasicDataSource.createConnectionFactory()
URL: https://github.com/apache/commons-dbcp/pull/33#discussion_r300068448
##########
File path:
src/test/java/org/apache/commons/dbcp2/TestOracleDriverConnectionFactory.java
##########
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.dbcp2;
+
+import java.sql.Connection;
+import java.sql.Driver;
+import java.sql.SQLException;
+import java.util.Properties;
+
+/**
+ * Simple ConnectionFactory impl class that use
BasicDataSource.createConnectionFactory()
+ */
+
+public class TestOracleDriverConnectionFactory implements ConnectionFactory {
+ private final String connectionString;
+ private final Driver driver;
+ private final Properties properties;
+
+ /**
+ * Constructs a connection factory for a given Driver.
+ *
+ * @param driver
+ * The Driver.
+ * @param connectString
+ * The connection string.
+ * @param properties
+ * The connection properties.
+ */
+ public TestOracleDriverConnectionFactory(final Driver driver, final String
connectString, final Properties properties) {
+ this.driver = driver;
+ this.connectionString = connectString;
+ this.properties = properties;
+ }
+
+ @Override
+ public Connection createConnection() throws SQLException {
+ Connection conn = driver.connect(connectionString, properties);
+ callOracleSetModule(conn);
+ return conn;
+ }
+
+ /**
+ * @return The connection String.
+ * @since 2.6.0
+ */
+ public String getConnectionString() {
+ return connectionString;
+ }
+
+ /**
+ * @return The Driver.
+ * @since 2.6.0
Review comment:
No need for @since and the version is wrong in any case.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 271740)
Time Spent: 1.5h (was: 1h 20m)
> Add a ConnectionFactory Interface in BasicDataSource class
> ----------------------------------------------------------
>
> Key: DBCP-547
> URL: https://issues.apache.org/jira/browse/DBCP-547
> Project: Commons DBCP
> Issue Type: Improvement
> Affects Versions: 2.2.0
> Reporter: Lee Jun Gyun
> Priority: Minor
> Time Spent: 1.5h
> Remaining Estimate: 0h
>
> It think it would be nice better to implement a ConnectionFactory interface
> in BasicDataSource class or implement a interface in DriverConnectionFactory
> class.
> In my current project, when getting a connection in my program, I call
> oracleSetModule.
> so, i think that after creating connection, call oracleSetModule via
> connectionFactoryImpl seems to be nice.
>
> [Before]
> protected ConnectionFactory createConnectionFactory() throws SQLException {
> ...
> ...
> ConnectionFactory driverConnectionFactory =
> new DriverConnectionFactory(driverToUse, url, connectionProperties);
> return driverConnectionFactory;
> }
> [After]
> protected ConnectionFactory createConnectionFactory() throws SQLException {
> ...
> ...
> ConnectionFactory driverConnectionFactory =
> getConnectionFactoryImpl().newInstance(...);
> return driverConnectionFactory;
> }
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)