首页 > 代码库 > ANT 测试

ANT 测试

 

 

--JDK HOME
C:\Program Files\Java\jdk1.7.0_79

--ANT HOME
D:\10\11\1121\apache-ant-1.9.7-bin

 

--file :sqlsample.xml

<?xml version="1.0" encoding="UTF-8"?>
<project name="DBHandler" basedir="." default="ConnectOracle">
<property name="oracleDriver" value="http://www.mamicode.com/oracle.jdbc.driver.OracleDriver"/>
<property name="oracleJar" location="C:\app\hupeng\product\11.2.0\client_1\jdbc\lib\ojdbc6.jar" />
<property name="oracleUrl" value="http://www.mamicode.com/jdbc:oracle:thin:@10.182.190.119:1521:UCM"/>
<property name="oracleUser" value="http://www.mamicode.com/peng" />
<property name="oraclePassword" value="http://www.mamicode.com/peng" />
<property name="oracleFile" value="http://www.mamicode.com/oracle.sql" />

<target name="ConnectOracle">
<sql driver="${oracleDriver}"
url="${oracleUrl}"
userid="${oracleUser}"
password="${oraclePassword}"
classpath="${oracleJar}"
print="true">
<!--select * from t_role where role_wid= ‘Everyone‘;-->
<transaction src="http://www.mamicode.com/${oracleFile}"/>
</sql>
</target>
</project>

--file oracle.sql
select sysdate from dual;

-- excute:
ant -f sqlsample.xml
D:\10\11\1121\oracle>ant -f sample.xml
Buildfile: D:\10\11\1121\oracle\sample.xml

ConnectOracle:
[sql] Executing resource: D:\10\11\1121\oracle\oracle.sql
[sql] SYSDATE
[sql] 2016-11-21 18:07:25
[sql]
[sql] 0 rows affected
[sql] 1 of 1 SQL statements executed successfully

BUILD SUCCESSFUL
Total time: 7 seconds

 

ANT 测试