how_to_use_ant_query_data_and_mail
来源:互联网 发布:天翼校园mac怎么连接 编辑:程序博客网 时间:2024/06/02 14:44
下面的示例是一个用Ant执行数据库查询并通过Javamail发送邮件的例子,要完成相同的功能,请先安装下列步骤执行操作:
1、安装j2sdk1.4.2,并设置path和classpath
2、安装Ant161,加到path中去。
3、下载javamail-1.3.1,并在classpath中指定mail.jar
4、下载jaf-1.0.2,并在classpath中指定activation.jar
5、编辑buildfile文件,例如night_build.xml。
6、执行:ant -buildfile night_build.xml
7、添加计划任务(Linux下采用cron),定时执行以上脚本就可以实现nightly building。
night_build.xml脚本如下:
<?xml version="1.0" encoding="GB2312"?>
<project default="init" name="Project Argon">
<description>
A Simple project doing the nightly build in ant build file
</description>
<property name="sqlDir" location="sql"/>
<property name="logDir" location="log"/>
<property name="attachmentDir" location="attachment"/>
<tstamp>
<format property="creDate" pattern="yyyy-MM-dd"/>
</tstamp>
<!-- XML comments can also be used -->
<target name="init">
<mkdir dir="${sqlDir}"/>
<mkdir dir="${logDir}"/>
<mkdir dir="${attachment}"/>
<sql
driver="oracle.jdbc.driver.OracleDriver"
url="jdbc:oracle:thin:@192.168.15.250:1521:ycdb"
userid="training"
password="deep1704sea"
src="./sql/queryData.sql"
showheaders="false"
print="yes"
output="${attachmentDir}/outputfile${creDate}.txt"
>
</sql>
<mail mailhost="email.ctgpc.com.cn" mailport="25" subject="TGPMS一周数据报告_${creDate}" charset="utf-8">
<from address="xu_yunsheng@ctgpc.com.cn"/>
<to address="xu_yunsheng@ctgpc.com.cn"/>
<message>您现在看到的是由系统发出的TGPMS一周数据报告.</message>
<fileset dir="${attachmentDir}">
<include name="*.txt"/>
</fileset>
</mail>
</target>
</project>
queryData.sql脚本如下:
SELECT 'Nightly Building begining: '||sysdate FROM dual;
SELECT '昨日D8512中新增'||COUNT(*)||'条工序编号' FROM process_no
WHERE modify_date>=sysdate-1;
SELECT '昨日D8512中新增'||COUNT(*)||'条指标编号' FROM process_test_index
WHERE modify_date>=sysdate-1;
- how_to_use_ant_query_data_and_mail
- 【时间】
- Oracle10g + Solaris9 for x86 + vmware安装步骤
- 10。1日 热血!改卷子ing
- 10.7 重新再来吧……
- 10/01/2004 在lougheed停车场来一杯mocha如何?
- how_to_use_ant_query_data_and_mail
- 上海MVP峰会上部分来自CSDN的MVP合影
- D3DXMatrixAffineTransformation函数
- 变量初始化
- Windows XP 中的入站连接限制
- D3DXMatrixAffineTransformation2D 函数
- 选择排序存档
- .net framework 1.0.3705.0 与 1.1.4322 的小小差异
- 怎样把login从一个SQL Server 2000实例导入到另一个实例