Hi,
My ant build does work without specifying a -cp option to ant. I run this
ant use-main dbd-apply-deltas
I do however specify the driver class:
<target name="dbd-generate-delta-script" description="uses dbdeploy
to generate the update and undo scripts" depends="db-selected">
<property name="out" value="${basedir}/db-deltas-${db.name}.sql"/>
<property name="out-undo"
value="${basedir}/db-deltas-${db.name}-UNDO.sql"/>
<dbdeploy
driver="${db.driver}"
url="${db.url}"
userid="${db.dba.username}"
password="${db.dba.password}"
dir="${basedir}/db-deltas"
outputfile="${out}"
dbms="mysql"
undoOutputfile="${out-undo}"
/>
<!-- To allow delimitertype="row" to work in the sql task it is
necessary to move ;'s onto their own line, and to replace \g with ;
-->
<replace_terminators file="${out}"/>
<replace_terminators file="${out-undo}"/>
</target>
I also specify the MySQL driver jar in the macrodef
<macrodef name="exec_sql">
<attribute name="src"/>
<attribute name="user"/>
<attribute name="password"/>
<attribute name="onerror"/>
<attribute name="delimitertype"/>
<sequential>
<sql
classpath="${mysql-connector.jar}"
driver="${db.driver}"
url="${db.url}"
userid="@{user}"
password="@{password}"
src="@{src}"
onerror="@{onerror}"
delimitertype="@{delimitertype}"
/>
</sequential>
</macrodef>
All the best,
-Janek
On 05/02/2008, sprytel <dwe...@gmail.com> wrote:
> Hrmm...
> I created a build file based off what you posted above... with the
> biggest difference being the use of an Oracle db driver instead of
> Mysql. When I execute, I get the following:
> C:\applic>ant -f db-build.xml
> Buildfile: db-build.xml
> dbd-generate-delta-script:
> [dbdeploy] Reading change scripts from directory C:\applic\db
> \migration...
> [dbdeploy] dbdeploy v2.11
> BUILD FAILED
> C:\applic\db-build.xml:43: C:\applic\db-build.xml:43: Class Not Found:
> JDBC driv
> er oracle.jdbc.OracleDriver could not be loaded
> Total time: 0 seconds
> C:\applic>ant -cp lib/oracle-10.2.0.1.jar -f db-build.xml
> Buildfile: db-build.xml
> dbd-generate-delta-script:
> [dbdeploy] Reading change scripts from directory C:\applic\db
> \migration...
> [dbdeploy] dbdeploy v2.11
> [dbdeploy] Changes currently applied to database:
> [dbdeploy] 1..11
> [dbdeploy] Scripts available:
> [dbdeploy] 1..11
> [dbdeploy] To be applied:
> [dbdeploy] (none)
> BUILD SUCCESSFUL
> Total time: 1 second
> As you can see, it doesn't seem to be able to find that Oracle driver
> unless I add it to the classpath when starting Ant.
> I have noticed this same thing in the "dbdeploy-demo" examples as
> well-- that they explicitly specify the library in a build batch
> file. For instance:
> ant -buildfile build-hsql.xml apply-deltas -lib .\lib\dbdeploy.jar -
> lib .\lib\hsqldb.jar
> So, I guess I'm confused. Does your Ant build really work without
> specifying the driver? Or are you passing them in-- either directly,
> or indirectly via a batch file or some such?
> I appreciate the help. Thanks!
> -Tim,