[ 
https://issues.apache.org/jira/browse/DBCP-231?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Phil Steitz updated DBCP-231:
-----------------------------

    Fix Version/s: 1.4

> Automatic Restart of BasicDataSource After Changing Connection Properties 
> Such as Url
> -------------------------------------------------------------------------------------
>
>                 Key: DBCP-231
>                 URL: https://issues.apache.org/jira/browse/DBCP-231
>             Project: Commons Dbcp
>          Issue Type: New Feature
>    Affects Versions: 1.3
>            Reporter: Joe Kelly
>            Priority: Minor
>             Fix For: 1.4
>
>
> It would be nice if BasicDataSource could automatically "restart" after 
> changing a connection property. For example, in our application, we sometimes 
> have to change the connection url at runtime (i.e. we are connected to one 
> database and then, under certain conditions, we switch to another database). 
> Currently, we workaround this limitation by manually calling 
> BasicDataSource.close() after calling BasicDataSource.setUrl().
> Looking at the July 11, 2007 snapshot of the source code for BasicDataSource, 
> it appears that the author was _starting_ to implement this feature. If you 
> look at many of the setters such as setUrl(), setUsername() and 
> setPassword(), you will see this line of code after the corresponding 
> instance variable is set:
>   this.restartNeeded = true;
> Furthermore, there is this private restart() method (notice the comment "not 
> used currently"):
>   /**
>     * Not used currently
>     */
>   private void restart() {
>       try {
>           close();
>       } catch (SQLException e) {
>           log("Could not restart DataSource, cause: " + e.getMessage());
>       }
>   }
> To finish implementing this, I think you would only need to add the following 
> snippet at the very top of createDataSource():
>   if (restartNeeded) {
>     restart();
>   }
> Some users might not like this feature because it might possibly cause active 
> connections to be killed abruptly (I'm not sure though because I haven't 
> really looked at the implementation of close() very closely). To calm their 
> fears, perhaps you could make this auto-restart feature optional by adding a 
> boolean property called  "restartable". Then you could modify my snippet to 
> this:
>   if (restartable && restartNeeded) {
>     restart();
>   }
> Anyway, just my two cents. I think the class is already pretty useful.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to