[
https://issues.apache.org/jira/browse/DBCP-231?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Mark Thomas resolved DBCP-231.
------------------------------
Resolution: Won't Fix
Fix Version/s: (was: 2.0)
There are may edge cases associated with restarting the DataSource that would
need careful thought and some complex code to solve - as well as a bunch of new
configuration options.
This is better handled by the client of DBCP on a case by case basis.
For those using DBCP in a container environment, the container may well support
a feature like Apache Tomcat's parallel deployment feature which would provide
a clean, simple and transparent way of handling changes to the configuration of
the DataSource.
The partial implementation of restart has been removed from the 2.x code base.
> 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
>
> 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 was sent by Atlassian JIRA
(v6.1.5#6160)