日期:2014-05-16  浏览次数:20510 次

使用Ant执行数据库DDL语句
<?xml version="1.0" encoding="ISO-8859-1"?>
<project name="TEST" basedir="." default="execute-ddl">
	<property file="install.properties" />
	<path id="build.classpath">
		<fileset dir="../WebContent/WEB-INF/lib">
			<include name="*.jar" />
		</fileset>
		<!-- We need the servlet API classes: -->

		<pathelement path="${dir.dist}" />
	</path>
	<target name="execute-ddl" depends="db.CREATE_MAIN">
		<echo message="Begin to install DB package - DDL:" />

		<!-- <version version="0" appid="DROP_MAIN" target="db.DROP_MAIN" /> -->
	</target>


	<target name="db.CREATE_MAIN" unless="new.version.CREATE_MAIN">
		<echo message="Begin to install crm-create.sql ..." />
		<sql classpathref="build.classpath" driver="${db.driver}" url="${db.url}"
			userid="${db.user}" password="${db.pass}" src="crm-create.sql">

		</sql>
		<echo message="Install crm-create.sql successfully!" />

</target>
</project>


-----install.properties
db.driver=oracle.jdbc.driver.OracleDriver
db.user=2wsxcde3
db.pass=2wsxcde3
db.url=jdbc:oracle:thin:@localhost:1521:orcl


这里需要引入一个properties文件和SQL脚本。