Generating a change log with diffDatabaseToChangeLog


I have a hibernate project and I want to generate a change log using ant
and the hibernate mapping files.  I fail with the error message appearing
below.  The DB is MySQL.

The snippet from the ant build.xml:


  <target name=“hibernate-changelog”
      description=“Create a change log file for liquibase.”>


I have checked that I can connect to the database by other means: both
command line and using jdbc.  So the user account in the database has
been set up correctly.

The MySQL logs show that an attempt was made to connect but there is
no information saying that access was denied.

The stacktrace shows that the method ‘createDatabaseObject’ in the
class cannot get a

More information below.  Any help is greatly appreciated.


JDK 1.6.0_20
mysql: 5.1.15 (with matching jdbc driver)

liquibase.exception.DatabaseException: Connection could not be created to hibernate:src/resources/hibernate.cfg.xml with driver com.mysql.jdbc.Driver.  Possibly the wrong driver for the given database URL
    at liquibase.integration.ant.BaseLiquibaseTask.createDatabaseObject(
    at liquibase.integration.ant.DiffDatabaseTask.execute(
    [ rest of stack trace deleted as it is standard ant stack. ]

What liquibase version are you using?


Hi Nathan,

Oh, sorry, I can’t believe I forgot to mention that: Liquibase version 2.0.
Also, here is what I would really like to be able to do.

Given an two versions of the hibernate mapping files (call them 'old’
and ‘new’), generate the Liquibase changelog.

What I am doing at the moment is to generate an empty DB using
the new mappings and letting Liquibase generate the changelog
just using ‘diffDatabaseToChangeLog’ (from Ant).  This works well of course.

Thanks a lot for replying.


PS: The delay in my response is because I was travelling.

In theory we can support diffing two hibernate mappings, but at this point we cannot and so your work-aroudn is the best option.  I am hoping to get to improving hibernate support soon and I’ll keep that feature in mine.


I think your error is because your reference database has a hibernate url but listing the mysql driver. You should be fine to remove the referenceDriver parameter.