Generating a change log with diffDatabaseToChangeLog

Hi,

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.”>
 
   
     
   

    <diffDatabaseToChangeLog
       referenceDriver=“com.mysql.jdbc.Driver”
       url=“jdbc:mysql://localhost:3306/migtest”
       referenceUrl=“hibernate:src/resources/hibernate.cfg.xml”
       username="${username}"
       password="${password}"
       outputFile=“liquibase/changelog.xml”
       classpathref=“lclasspath”/>
 

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 liquibase.integration.ant.BaseLiquibaseTask.java cannot get a
connection.

More information below.  Any help is greatly appreciated.
Thanks,

Ravi/

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(BaseLiquibaseTask.java:241)
    at liquibase.integration.ant.DiffDatabaseTask.execute(DiffDatabaseTask.java:98)
    [ rest of stack trace deleted as it is standard ant stack. ]

What liquibase version are you using?

Nathan

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.

Ravi/

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.


Nathan

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.


Nathan