How to specify the database class when using the databaseClass option?

I am not sure if I using the databaseClass option

–databaseClass=liquibase.database.PostgresDatabase

I get the follow error below when I am do  update or diff:

Liquibase Update Failed: PostgresDatabase.  For more information, use the --logLevel flag)
Jul 15, 2010 10:53:20 AM liquibase.logging.jvm.JavaUtilLogger info
INFO: liquibase.database.PostgresDatabase
liquibase.exception.DatabaseException: java.lang.ClassNotFoundException: liquibase.database.PostgresDatabase
at liquibase.integration.commandline.CommandLineUtils.createDatabaseObject(CommandLineUtils.java:77)
at liquibase.integration.commandline.Main.doMigration(Main.java:599)
at liquibase.integration.commandline.Main.main(Main.java:105)
Caused by: java.lang.ClassNotFoundException: PostgresDatabase
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:323)
at java.lang.ClassLoader.loadClass(ClassLoader.java:268)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:336)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at liquibase.integration.commandline.CommandLineUtils.createDatabaseObject(CommandLineUtils.java:44)
… 2 more

You shouldn’t need to, it should be able to tell from your jdbc url.  The databaseClass option is for creating your own custom database class. You should just be able to have the class in the classpath.

Nathan

Right, but you should be able get the Postgres class to load thru it is redundant. I am attempt to create a modified version of Postgres database class for EnterprsieDB, but I am unable to get it to work correctly.  How will my new database class work if you cannot even find the liquibase.database.PostgesDatabase class.

Yes, it should work.  What version of liquibase are you running?

Natha

I was using the last Liquibase 2.0 rc1 version, but I same thing again with the rc2 build …same error.

With 2.0, the class name/package has changed to liquibase.database.core.PostgresDatabase.  Does that help?

Nathan

I am using CommandLineUtils.createDatabaseObject from my Java code to create the Database instance.

What I find is that if I don’t pass in the databaseClass it fails as DatabaseFactory.findDefaultDriver iterates through implementedDatabases which only has registered entries.  So if no databaseClass then no registry and no driver.

Must I not use CommandLineUtils for this purpose or is there another way of doing it which doesn’t require the databaseClass to be passed?

Passing DatabaseClass should work still.  I looked into a bit more, and think I found the bug.  Try it now.

With 2.0, I made significant changes to better support extensibility/plug-ins, including with the database class to use.  You should now be able to eitse.exther create a class in a sub-package of liquibase.ext or liquibase.database.ext, or add the package your class is in to your MANFEST.MF file under a value of Liquibase-Package.  If your class extends the standard liquibase database class, you just  have to override getPriority() to return a higher value (10 or higher will work with the core liquibase classes).  If you have a normally unsupported database, or no inheritance connection, there is a isCorrectDatabaseImplementation() method to override.  

There is more info (and more being written soon) on the 2.0 extensibility at http://liquibase.org/extensions

Nathan