You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by GitBox <gi...@apache.org> on 2020/08/10 15:42:48 UTC

[GitHub] [commons-dbcp] garydgregory commented on a change in pull request #50: Add start, restart methods to BasicDataSource. JIRA: DBCP-559.

garydgregory commented on a change in pull request #50:
URL: https://github.com/apache/commons-dbcp/pull/50#discussion_r467998603



##########
File path: src/main/java/org/apache/commons/dbcp2/BasicDataSource.java
##########
@@ -433,6 +433,55 @@ public synchronized void close() throws SQLException {
         }
     }
 
+    /**
+     * Starts the datasource.
+     * <p>
+     * It is not necessary to call this method before using a newly created BasicDataSource instance, but
+     * calling it in that context causes the datasource to be immediately initialized (instead of waiting for
+     * the first {@link #getConnection()} request). Its primary use is to restart and reinitialize a
+     * datasource that has been closed.
+     * <p>
+     * When this method is called after {@link #close()}, connections checked out by clients
+     * before the datasource was stopped do not count in {@link #getMaxTotal()} or {@link #getNumActive()}.
+     * For example, if there are 3 connections checked out by clients when {@link #close()} is invoked and they are
+     * not returned before {@link #start()} is invoked, after this method is called, {@link #getNumActive()} will
+     * return 0.  These connections will be physically closed when they are returned, but they will not count against
+     * the maximum allowed in the newly started datasource.
+     *
+     * @throws SQLException if an error occurs initializing the datasource
+     */
+    @Override
+    public synchronized void start() throws SQLException {

Review comment:
       Since `createDataSource()` returns a `DataSource`, it would seem proper for this method to return it as well.




----------------------------------------------------------------
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:
users@infra.apache.org