Why is --driver required?

Shouldn’t Liquibase be able to use DriverManager to find the proper driver based off the URL?

Best,
Laird


http://about.me/lairdnelson

Yes; I’m quite familiar with the jdbc.drivers property (documented in the same class).

I understand this property is convenient, and is nice to have, but should it be required?

Best,
Laird


http://about.me/lairdnelson

The JDBC driver class must be loaded and linked (that results in invocation of the static initializer of the driver class) so that it can register itself with DriverManager. Only after a driver class is registered DriverManager can find the class.


This also explains why we need Class.forName(driverClassName) before calling DriverManager.getConnection() when using vanilla JDBC.


Hence, we must know the Driver class name before we can obtain a connection. HTH.


Shantanu


P.S.: It is of course possible to “guess” the driver class name based on the JDBC URL, but that sounds like an exercise in limited versus non-trivial.

It’s marked as required here: http://liquibase.org/manual/command_line#required_parameters


http://about.me/lairdnelson

It looks like --driver is optional, as it should be. If you don’t specify it it sets it off the defaultDriver property on the liquibase Database objects.


Where are you seeing it required?


Nathan

Ok, thanks. I’ll get that doc changes. The code doesn’t look like it’s enforcing that.


Nathan