Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Tutorials Ant Ant Script to Create Mysql Table

Related Tutorials


 
 

Share on Google+Share on Google+

Ant Script to Create Mysql Table

Advertisement
This example illustrates how to create table through the build.xml file by simply running the ant command.

Ant Script to Create Mysql Table

     

This example illustrates how to create 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, only one target <target name="createTables"> is used to execute the query which is in the client.sql and project.sql file. The source code of the build.xml file is as follows:

<project name="MysqlCreateTable" basedir="." default="createTables">

  <property name="sql.driver" value="org.gjt.mm.mysql.Driver"/>
  <property name="sql.url" value="jdbc:mysql://192.168.10.211/test"/>
  <property name="sql.user" value="sandeep"/>
  <property name="sql.pass" value="sandeep"/>

  <target name="createTables">
  <sql driver="${sql.driver}" url="${sql.url}" userid="${sql.user}" 
    password=
"${sql.pass}" >
  <transaction src="client.sql"/>
  <transaction src="project.sql"/>
  </sql>
  </target>

</project>

 client.sql

create table client (
  client_id int not null auto_increment primary key,
  client_name text not null
);

project.sql

create table project (
  project_id int not null auto_increment primary key,
  project_name text not null
);

Create the both client.sql and project.sql files with 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.


Download Source Code

     

Advertisement

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: September 6, 2008

Related Tutorials

Discuss: Ant Script to Create Mysql Table   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:1
Francisco
February 23, 2012
XpbQavggrUAcHNlPjIH

I'm not sure how you would do it with Expression Engine, but the way to cgnahe the SQL mode at runtime is to set a session-specific mode with the following SQL query:SET sql_mode = 'TRADITIONAL'
DMCA.com