This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-dbcp.git
The following commit(s) were added to refs/heads/master by this push: new d69e6a51 Use the term "connection string" instead of "url" d69e6a51 is described below commit d69e6a510328570c9839b31028b723d5e3669036 Author: Gary Gregory <gardgreg...@gmail.com> AuthorDate: Tue Aug 30 09:03:58 2022 -0400 Use the term "connection string" instead of "url" --- .../org/apache/commons/dbcp2/BasicDataSource.java | 20 +- .../dbcp2/DriverManagerConnectionFactory.java | 296 ++++++++++----------- .../dbcp2/cpdsadapter/DriverAdapterCPDS.java | 26 +- 3 files changed, 171 insertions(+), 171 deletions(-) diff --git a/src/main/java/org/apache/commons/dbcp2/BasicDataSource.java b/src/main/java/org/apache/commons/dbcp2/BasicDataSource.java index 29fdcdd7..37b05c18 100644 --- a/src/main/java/org/apache/commons/dbcp2/BasicDataSource.java +++ b/src/main/java/org/apache/commons/dbcp2/BasicDataSource.java @@ -292,9 +292,9 @@ public class BasicDataSource implements DataSource, BasicDataSourceMXBean, MBean private volatile String password; /** - * The connection URL to be passed to our JDBC driver to establish a connection. + * The connection string to be passed to our JDBC driver to establish a connection. */ - private String url; + private String connectionString; /** * The connection user name to be passed to our JDBC driver to establish a connection. @@ -451,7 +451,7 @@ public class BasicDataSource implements DataSource, BasicDataSourceMXBean, MBean * with the specified {@link ClassLoader}.</li> * <li>If {code driverClassName} is specified and the previous attempt fails, the class is loaded using the * context class loader of the current thread.</li> - * <li>If a driver still isn't loaded one is loaded via the {@link DriverManager} using the specified {code url}. + * <li>If a driver still isn't loaded one is loaded via the {@link DriverManager} using the specified {code connectionString}. * </ol> * <p> * This method exists so subclasses can replace the implementation class. @@ -1426,13 +1426,13 @@ public class BasicDataSource implements DataSource, BasicDataSourceMXBean, MBean } /** - * Gets the JDBC connection {code url} property. + * Gets the JDBC connection {code connectionString} property. * - * @return the {code url} passed to the JDBC driver to establish connections + * @return the {code connectionString} passed to the JDBC driver to establish connections */ @Override public synchronized String getUrl() { - return this.url; + return this.connectionString; } /** @@ -2485,17 +2485,17 @@ public class BasicDataSource implements DataSource, BasicDataSourceMXBean, MBean } /** - * Sets the {code url}. + * Sets the {code connection string}. * <p> * Note: this method currently has no effect once the pool has been initialized. The pool is initialized the first * time one of the following methods is invoked: <code>getConnection, setLogwriter, * setLoginTimeout, getLoginTimeout, getLogWriter.</code> * </p> * - * @param url the new value for the JDBC connection url + * @param connectionString the new value for the JDBC connection connectionString */ - public synchronized void setUrl(final String url) { - this.url = url; + public synchronized void setUrl(final String connectionString) { + this.connectionString = connectionString; } /** diff --git a/src/main/java/org/apache/commons/dbcp2/DriverManagerConnectionFactory.java b/src/main/java/org/apache/commons/dbcp2/DriverManagerConnectionFactory.java index 9e6b86b6..4564442a 100644 --- a/src/main/java/org/apache/commons/dbcp2/DriverManagerConnectionFactory.java +++ b/src/main/java/org/apache/commons/dbcp2/DriverManagerConnectionFactory.java @@ -1,148 +1,148 @@ -/* - * 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.DriverManager; -import java.sql.SQLException; -import java.util.Properties; - -/** - * A {@link DriverManager}-based implementation of {@link ConnectionFactory}. - * - * @since 2.0 - */ -public class DriverManagerConnectionFactory implements ConnectionFactory { - - static { - // Related to DBCP-212 - // Driver manager does not sync loading of drivers that use the service - // provider interface. This will cause issues is multi-threaded - // environments. This hack makes sure the drivers are loaded before - // DBCP tries to use them. - DriverManager.getDrivers(); - } - - private final String connectionUri; - - private final String userName; - - private final char[] userPassword; - - private final Properties properties; - - /** - * Constructor for DriverManagerConnectionFactory. - * - * @param connectionUri - * a database url of the form {@code jdbc:<em>subprotocol</em>:<em>subname</em>} - * @since 2.2 - */ - public DriverManagerConnectionFactory(final String connectionUri) { - this.connectionUri = connectionUri; - this.properties = new Properties(); - this.userName = null; - this.userPassword = null; - } - - /** - * Constructor for DriverManagerConnectionFactory. - * - * @param connectionUri - * a database url of the form {@code jdbc:<em>subprotocol</em>:<em>subname</em>} - * @param properties - * a list of arbitrary string tag/value pairs as connection arguments; normally at least a "user" and - * "password" property should be included. - */ - public DriverManagerConnectionFactory(final String connectionUri, final Properties properties) { - this.connectionUri = connectionUri; - this.properties = properties; - this.userName = null; - this.userPassword = null; - } - - /** - * Constructor for DriverManagerConnectionFactory. - * - * @param connectionUri - * a database url of the form {@code jdbc:<em>subprotocol</em>:<em>subname</em>} - * @param userName - * the database user - * @param userPassword - * the user's password - */ - public DriverManagerConnectionFactory(final String connectionUri, final String userName, - final char[] userPassword) { - this.connectionUri = connectionUri; - this.userName = userName; - this.userPassword = Utils.clone(userPassword); - this.properties = null; - } - - /** - * Constructor for DriverManagerConnectionFactory. - * - * @param connectionUri - * a database url of the form {@code jdbc:<em>subprotocol</em>:<em>subname</em>} - * @param userName - * the database user - * @param userPassword - * the user's password - */ - public DriverManagerConnectionFactory(final String connectionUri, final String userName, - final String userPassword) { - this.connectionUri = connectionUri; - this.userName = userName; - this.userPassword = Utils.toCharArray(userPassword); - this.properties = null; - } - - @Override - public Connection createConnection() throws SQLException { - if (null == properties) { - if (userName == null && userPassword == null) { - return DriverManager.getConnection(connectionUri); - } - return DriverManager.getConnection(connectionUri, userName, Utils.toString(userPassword)); - } - return DriverManager.getConnection(connectionUri, properties); - } - - /** - * @return The connection URI. - * @since 2.6.0 - */ - public String getConnectionUri() { - return connectionUri; - } - - /** - * @return The Properties. - * @since 2.6.0 - */ - public Properties getProperties() { - return properties; - } - - /** - * @return The user name. - * @since 2.6.0 - */ - public String getUserName() { - return userName; - } -} +/* + * 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.DriverManager; +import java.sql.SQLException; +import java.util.Properties; + +/** + * A {@link DriverManager}-based implementation of {@link ConnectionFactory}. + * + * @since 2.0 + */ +public class DriverManagerConnectionFactory implements ConnectionFactory { + + static { + // Related to DBCP-212 + // Driver manager does not sync loading of drivers that use the service + // provider interface. This will cause issues is multi-threaded + // environments. This hack makes sure the drivers are loaded before + // DBCP tries to use them. + DriverManager.getDrivers(); + } + + private final String connectionUri; + + private final String userName; + + private final char[] userPassword; + + private final Properties properties; + + /** + * Constructor for DriverManagerConnectionFactory. + * + * @param connectionUri + * a database connection string of the form {@code jdbc:<em>subprotocol</em>:<em>subname</em>} + * @since 2.2 + */ + public DriverManagerConnectionFactory(final String connectionUri) { + this.connectionUri = connectionUri; + this.properties = new Properties(); + this.userName = null; + this.userPassword = null; + } + + /** + * Constructor for DriverManagerConnectionFactory. + * + * @param connectionUri + * a database connection string of the form {@code jdbc:<em>subprotocol</em>:<em>subname</em>} + * @param properties + * a list of arbitrary string tag/value pairs as connection arguments; normally at least a "user" and + * "password" property should be included. + */ + public DriverManagerConnectionFactory(final String connectionUri, final Properties properties) { + this.connectionUri = connectionUri; + this.properties = properties; + this.userName = null; + this.userPassword = null; + } + + /** + * Constructor for DriverManagerConnectionFactory. + * + * @param connectionUri + * a database connection string of the form {@code jdbc:<em>subprotocol</em>:<em>subname</em>} + * @param userName + * the database user + * @param userPassword + * the user's password + */ + public DriverManagerConnectionFactory(final String connectionUri, final String userName, + final char[] userPassword) { + this.connectionUri = connectionUri; + this.userName = userName; + this.userPassword = Utils.clone(userPassword); + this.properties = null; + } + + /** + * Constructor for DriverManagerConnectionFactory. + * + * @param connectionUri + * a database connection string of the form {@code jdbc:<em>subprotocol</em>:<em>subname</em>} + * @param userName + * the database user + * @param userPassword + * the user's password + */ + public DriverManagerConnectionFactory(final String connectionUri, final String userName, + final String userPassword) { + this.connectionUri = connectionUri; + this.userName = userName; + this.userPassword = Utils.toCharArray(userPassword); + this.properties = null; + } + + @Override + public Connection createConnection() throws SQLException { + if (null == properties) { + if (userName == null && userPassword == null) { + return DriverManager.getConnection(connectionUri); + } + return DriverManager.getConnection(connectionUri, userName, Utils.toString(userPassword)); + } + return DriverManager.getConnection(connectionUri, properties); + } + + /** + * @return The connection URI. + * @since 2.6.0 + */ + public String getConnectionUri() { + return connectionUri; + } + + /** + * @return The Properties. + * @since 2.6.0 + */ + public Properties getProperties() { + return properties; + } + + /** + * @return The user name. + * @since 2.6.0 + */ + public String getUserName() { + return userName; + } +} diff --git a/src/main/java/org/apache/commons/dbcp2/cpdsadapter/DriverAdapterCPDS.java b/src/main/java/org/apache/commons/dbcp2/cpdsadapter/DriverAdapterCPDS.java index 8c0b4f49..45140185 100644 --- a/src/main/java/org/apache/commons/dbcp2/cpdsadapter/DriverAdapterCPDS.java +++ b/src/main/java/org/apache/commons/dbcp2/cpdsadapter/DriverAdapterCPDS.java @@ -91,8 +91,8 @@ public class DriverAdapterCPDS implements ConnectionPoolDataSource, Referenceabl /** Description */ private String description; - /** Url name */ - private String url; + /** Connection string */ + private String connectionString; /** User name */ private String userName; @@ -288,7 +288,7 @@ public class DriverAdapterCPDS implements ConnectionPoolDataSource, Referenceabl if (isNotEmpty(ra)) { setDriver(getStringContent(ra)); } - ra = ref.get("url"); + ra = ref.get("connectionString"); if (isNotEmpty(ra)) { setUrl(getStringContent(ra)); } @@ -449,7 +449,7 @@ public class DriverAdapterCPDS implements ConnectionPoolDataSource, Referenceabl ref.add(new StringRefAddr("loginTimeout", String.valueOf(getLoginTimeout()))); ref.add(new StringRefAddr(Constants.KEY_PASSWORD, getPassword())); ref.add(new StringRefAddr(Constants.KEY_USER, getUser())); - ref.add(new StringRefAddr("url", getUrl())); + ref.add(new StringRefAddr("connectionString", getUrl())); ref.add(new StringRefAddr("poolPreparedStatements", String.valueOf(isPoolPreparedStatements()))); ref.add(new StringRefAddr("maxIdle", String.valueOf(getMaxIdle()))); @@ -485,12 +485,12 @@ public class DriverAdapterCPDS implements ConnectionPoolDataSource, Referenceabl } /** - * Gets the value of url used to locate the database for this datasource. + * Gets the value of connection string used to locate the database for this data source. * - * @return value of url. + * @return value of connection string. */ public String getUrl() { - return url; + return connectionString; } /** @@ -740,14 +740,14 @@ public class DriverAdapterCPDS implements ConnectionPoolDataSource, Referenceabl } /** - * Sets the value of URL string used to locate the database for this datasource. + * Sets the value of URL string used to locate the database for this data source. * - * @param url Value to assign to url. + * @param connectionString Value to assign to connection string. * @throws IllegalStateException if {@link #getPooledConnection()} has been called */ - public void setUrl(final String url) { + public void setUrl(final String connectionString) { assertInitializationAllowed(); - this.url = url; + this.connectionString = connectionString; } /** @@ -772,10 +772,10 @@ public class DriverAdapterCPDS implements ConnectionPoolDataSource, Referenceabl final StringBuilder builder = new StringBuilder(super.toString()); builder.append("[description="); builder.append(description); - builder.append(", url="); + builder.append(", connectionString="); // TODO What if the connection string contains a 'user' or 'password' query parameter but that connection string // is not in a legal URL format? - builder.append(url); + builder.append(connectionString); builder.append(", driver="); builder.append(driver); builder.append(", loginTimeout=");