[ 
https://issues.apache.org/jira/browse/DBCP-559?focusedWorklogId=468706&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-468706
 ]

ASF GitHub Bot logged work on DBCP-559:
---------------------------------------

                Author: ASF GitHub Bot
            Created on: 10/Aug/20 15:42
            Start Date: 10/Aug/20 15:42
    Worklog Time Spent: 10m 
      Work Description: 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:
us...@infra.apache.org


Issue Time Tracking
-------------------

            Worklog Id:     (was: 468706)
    Remaining Estimate: 40m  (was: 50m)
            Time Spent: 20m  (was: 10m)

> 数据库连接可以通过BasicDataSource类的close()方法进行关闭,但该类没有提供open()方法使得新建的数据库连接生效
> -------------------------------------------------------------------
>
>                 Key: DBCP-559
>                 URL: https://issues.apache.org/jira/browse/DBCP-559
>             Project: Commons DBCP
>          Issue Type: Improvement
>    Affects Versions: 2.8.0
>            Reporter: Wenzhi Ji
>            Priority: Major
>              Labels: ready-to-commit
>             Fix For: 2.8.0
>
>         Attachments: BasicDataSource.java, BasicDataSourceMXBean.java
>
>   Original Estimate: 1h
>          Time Spent: 20m
>  Remaining Estimate: 40m
>
> 当前该开源软件具备的功能:若数据库连接被关闭(即closed置为true),则必须重启服务,才能使新的数据库连接生效(closed置为false)。
> 针对容灾场景,若数据库连接串发生变化,为了使新的数据库连接动态生效(热生效),不需要手工重启服务,建议该开源软件BasicDataSource类提供一个open()方法用于置closed
>  = false;以使建立的数据库连接生效。
> 变更的代码见附件。
> 注:附件是基于2.7.0版本代码进行优化的。



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to