Merge pull request #1574 from nlivens/mysql_driver_issue

Make sure that the DB drivers are loaded before creating connectionsI've digged 
deeper, and found out that Tomcat is really specific in how it loads the JDBC 
drivers apparently.
If we would be using the standard JDBC connection pooling of Tomcat 
(tomcat-jdbc) instead of commons-dbcp, we would have the option to specify a 
"driverClassName" when creating our connection.
This is not the case for commons-dbcp, which we are using within ACS.

If you check an official example of Tomcat :
https://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html#Plain_Ol'_Java
or
https://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html#As_a_Resource

As you can see in the above examples, both of them specify the driverClassName.
In the underlying implementation of Tomcat, Tomcat will do 
```Class.forName(driverClassName)``` which will trigger the auto-registration 
of the Driver.

Tomcat code :
```java
            if (driver==null) {
                if (log.isDebugEnabled()) {
                    log.debug("Instantiating driver using class: 
"+poolProperties.getDriverClassName()+" [url="+poolProperties.getUrl()+"]");
                }
                driver = (java.sql.Driver) 
Class.forName(poolProperties.getDriverClassName(),
                                                         true, 
PooledConnection.class.getClassLoader()
                                                         ).newInstance();
            }
```

* pr/1574:
  Make sure that the DB drivers are loaded before initiating connections

Signed-off-by: Will Stevens <[email protected]>


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/971c8a74
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/971c8a74
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/971c8a74

Branch: refs/heads/master
Commit: 971c8a74e487e1048dd85338b80baa15902858d4
Parents: bb9148b c956749
Author: Will Stevens <[email protected]>
Authored: Wed Jun 1 11:39:15 2016 -0400
Committer: Will Stevens <[email protected]>
Committed: Wed Jun 1 11:39:16 2016 -0400

----------------------------------------------------------------------
 .../db/src/com/cloud/utils/db/DriverLoader.java | 69 ++++++++++++++++++++
 .../com/cloud/utils/db/TransactionLegacy.java   | 18 +----
 2 files changed, 72 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


Reply via email to