Tobias Wittur
Tobias Wittur

Reputation: 73

Liquibase ANT Build.xml Oracle Driver

I am trying to run an ant script to deploy changes via liquibase.

<project name="Example" xmlns:liquibase="antlib:liquibase.integration.ant">

    <taskdef 
        resource="liquibase/integration/ant/antlib.xml" 
        uri="antlib:liquibase.integration.ant">

        <classpath path="C:\liquibase\lib\liquibase\"/>

    </taskdef>

  <property name="db.changelog.file" value="C:\projects\lbdemo\trunk\db_v4.xml"/>
  <property name="database.url" value="jdbc:oracle:thin:@mydb:1521:ORCL"/>
  <property name="database.username" value="myuser"/>
  <property name="database.password" value="mypassword"/>
  <property name="database.driver" value="oracle.jdbc.OracleDriver"/>

  <liquibase:database id="my-database" driver="${database.driver}" url="${database.url}" user="${database.username}" password="${database.password}"/>

  <liquibase:updateDatabase databaseref="my-database" changelogfile="${db.changelog.file}"/>

</project>

Installation Paths:

Tests

Error:

I am getting the below error when running the above ANT build:

C:\projects\lbdemo\trunk>ant

C:\projects\lbdemo\trunk\build.xml [liquibase:updateDatabase] Starting Liquibase.

BUILD FAILED C:\projects\lbdemo\trunk\build.xml:15: Class not found: oracle.jdbc.OracleDriver

Total time: 1 second

How can I tell liquibase in ant where the Oracle Driver sits?

I referred to: http://www.liquibase.org/documentation/ant/index.html

Upvotes: 0

Views: 1179

Answers (2)

Atul
Atul

Reputation: 1566

Easier way to do this is to put your all required(liquibase.jar and ojdbc7.jar) libraries into one directory and refer them using path id.

<path id="liquibaseClasspath">
    <fileset dir="C:\projects\lbdemo\trunk\lib" includes="*.jar" />
</path>
<target name="Upgrade_db">
    <echo message="Upgrading DataBase" />
    <updateDatabase changeLogFile="C:\projects\lbdemo\trunk\db_v4.xml" driver="${database.driver}" url="${database.url}" username="${database.username}" password="${database.password}"  classpathref="liquibaseClasspath" />
</target>

You can also mention all the directories location in one file and import that file in your ant file.

Upvotes: 0

Tobias Wittur
Tobias Wittur

Reputation: 73

Here the ant build.xml that ran successfully. The ojdbc driver and liquibase jars are both located in C:\liquibase\; which I reference in the updateDatabase tag: liquibase:updateDatabase classpathref="driver.classpath"

<project name="Example" xmlns:liquibase="antlib:liquibase.integration.ant">

  <path id="driver.classpath"> 
    <filelist dir="C:\liquibase\" > 
      <file name="ojdbc7.jar" /> 
      <file name="liquibase.jar" /> 
    </filelist> 
  </path>

  <property name="db.changelog.file" value="C:\projects\lbdemo\trunk\db_v4.xml"/>
  <property name="database.url" value="jdbc:oracle:thin:@mydb.rds.amazonaws.com:1521:ORCL"/>
  <property name="database.username" value="myuser"/>
  <property name="database.password" value="mypassword"/>
  <property name="database.driver" value="oracle.jdbc.OracleDriver"/>

  <liquibase:database id="my-database" driver="${database.driver}" url="${database.url}" user="${database.username}" password="${database.password}"/>

  <liquibase:updateDatabase classpathref="driver.classpath" databaseref="my-database" changelogfile="${db.changelog.file}"/>

</project>

Upvotes: 0

Related Questions