This example illustrates how to drop table through the build.xml file
by simply running the ant command. In this build.xml file, we are
using 4 property elements for connectivity of database. The first property <property
name="sql.driver"> is used to connect the sql driver. The
second property <property name="sql.url"> is used to
define the database url and database name. The third property <property
name="sql.user"> is used to define user name of the database.
The fourth property <property name="sql.pass"> is used
to define the password name of the database.
In this build.xml file, <target name="createTables"> is used to execute the query which is in the client.sql and project.sql file and <target name"dropTables"> is used to execute the query which is in the deleteclient.sql and deleteproject.sql file. In the target <target name="dropTable">, a condition is used - whether the user wants to delete the file or not. If the user gives input 'n', then the table can't be deleted but if the user give input 'y', then the table will be completely deleted. The source code of the build.xml file is as follows:
<project name="MysqlCreateTable" basedir="." default="dropTables">
create table client (
create table project (
drop table client;
drop table project;
Create the all client.sql, project.sql, deleteclient.sql, deleteproject.sql files parallel of the build.xml file and simply run the build.xml file with ant command in the appropriate path on command prompt. If the program executes successfully, then the following output will be displayed.
Rs. 20,000 US$ 300
Today: Rs. 10,000 US$150
Course Duration: 30 hrs
Posted on: September 6, 2008 If you enjoyed this post then why not add us on Google+? Add us to your Circles