Information Technology Reference
In-Depth Information
Developer:
build-database.xml:ANT:
build-database.xml:ANT:
database-definition.sql:
database-manipulation.sql:
DB:
db:prepare
filterSqlFiles
db:create
db:create
execute
db:insert
load
execute
The sequence of automated database integration
FIGURE 5-2
ior through stored procedures or functions. We are using Ant to auto-
mate the
execution
of this process in Listing 5-2; however, as
mentioned earlier, you can also use make, shell, batch, Rake, Ruby, or
any number of tools. Notice that Ant provides a task to execute a SQL
script via the
sql
task. Using a build platform like Ant allows you to
perform the database integration activities using a sequential approach
and enforce dependencies on other targets (a set of tasks) in the script.
The example in Listing 5-2 demonstrates the use of Ant's
sql
attributes, such as
driver
,
userid
,
and
password
, to connect to the
database.
build-database.xml: Defining Your Database Using an
LISTING 5-2
Ant Script
<target name="db:create" depends="filterSqlFiles" description="Create
the database definition">
<sql
driver="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/"
userid="root"
password="root"
classpathref="db.lib.path"
src="${filtered.sql.dir}/
database-definition.sql
"
delimiter="//"/>
</target>