转至繁体中文版     | 网站首页 | 图文教程 | 资源下载 | 站长博客 | 图片素材 | 武汉seo | 武汉网站优化 | 
最新公告:     敏韬网|教学资源学习资料永久免费分享站!  [mintao  2008年9月2日]        
您现在的位置: 学习笔记 >> 图文教程 >> 数据库 >> Sql Server >> 正文
Workshop8.1中使用ANT自动执行Sql         

Workshop8.1中使用ANT自动执行Sql

作者:闵涛 文章来源:闵涛的学习笔记 点击数:1138 更新时间:2007/11/14 12:53:54
这是个ant实现自动sql建表的例子,运行方法,在workshop中先建一个java project,倒入这三个文件,Build 这个java project,如果Ant窗口在workshop中没有显示,就选择 察看-〉窗口->ANT

执行sql时双击ANT窗口中的图标既可自动执行。


文件1:build.xml内容如下:
<?xml version="1.0"?>
<!-- =====================================================================
     Author: aaronsi
     Date:  05/25/2004
     ===================================================================== -->

<project name="Database"
         default="resetDB"
         basedir="">

    <property name="pointbase.dir"
              value="pointbase" />            

    <property name="pointbase.port"
              value="9093" />

    <property name="pointbase.db.driver"
              value="com.pointbase.jdbc.jdbcUniversalDriver" />

    <property name="pointbase.db.name"
              value="workshop" />       

    <property name="pointbase.host"
              value="localhost" />

    <property name="weblogic.home"
              value="@WL_HOME" />
          
    <path id="classpath.pointbase">
        <pathelement location="${weblogic.home}\common\eval\pointbase\lib\pbtools44.jar"/>
        <pathelement location="${weblogic.home}\common\eval\pointbase\lib\pbclient44.jar"/>
    </path>

    <target name="resetDB"
            description="Clear and repopulate the database"
            depends="createTables,buildDatabase"/>

    <target name="createTables"
            description="Drop and create the demo tables"
    >
        <antcall target="pbCommand">
            <param name="pbscript"
                   value="dbdemo_init.sql"/>
            <param name="pointbase.db.user"
                   value="weblogic"/>
            <param name="pointbase.db.password"
                   value="weblogic"/>                  
        </antcall>
    </target> 
   
    <target name="buildDatabase"
            description="Populate tables with data"
            depends="createTables">
        <antcall target="pbCommand">
            <param name="pbscript"
                   value="dbdemo_data.sql"/>
            <param name="pointbase.db.user"
                   value="weblogic"/>
            <param name="pointbase.db.password"
                   value="weblogic"/>                  
        </antcall>
    </target>                

    <target name="pbCommand"
            description="Starts the PointBase Client with a SQL script."
    >
            <echo message="${java.class.path}" />
            <echo message="User Dir: ${user.dir}" />
            <echo message="Project Dir: ${basedir}" />           
            <echo message="PB Script to run: ${basedir}/${pbscript}"/>
            <java classname="com.pointbase.tools.toolsCommander">
            <arg value="${pointbase.db.driver}" />
            <arg value="jdbc:pointbase://${pointbase.host}:${pointbase.port}/${pointbase.db.name}" />
            <arg value="${basedir}/${pbscript}" />
            <arg value="${pointbase.db.user}" />
            <arg value="${pointbase.db.password}" />
            <classpath>
                <path refid="classpath.pointbase" />
            </classpath>
        </java>
    </target>

</project> 


文件2:dbdemo_data.sql,内容如下:

insert into DEMO.usertable
(username, age,address) values
(''''aaron'''',25,''''Beijing''''),
(''''andy'''', 25,''''Shanghai'''')
;

文件3:dbdemo_init.sql,内容如下:

drop schema DEMO;
create schema DEMO;

create table DEMO.usertable
(
   userid integer identity  not null,
   username varchar2 ( 30),
   age int,
   address varchar2 ( 30),
   constraint PK_CUSTOMER primary key ( userid)
);


[Access]sql随机抽取记录  [Access]ASP&SQL让select查询结果随机排序的实现方法
[系统软件]SQL语句性能优化--LECCO SQL Expert  [C语言系列]SQL Server到DB2连接服务器的实现
[C语言系列]SQL Server到SYBASE连接服务器的实现  [C语言系列]SQL Server到SQLBASE连接服务器的实现
[C语言系列]SQL Server连接VFP数据库的实现  [C语言系列]ASP+SQL Server之图象数据处理
[C语言系列]SQL Server连接ACCESS数据库的实现  [C语言系列]DBA的最佳选择—图形界面还是T-SQL命令?
教程录入:mintao    责任编辑:mintao 
  • 上一篇教程:

  • 下一篇教程:
  • 【字体: 】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
      注:本站部分文章源于互联网,版权归原作者所有!如有侵权,请原作者与本站联系,本站将立即删除! 本站文章除特别注明外均可转载,但需注明出处! [MinTao学以致用网]
      网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)

    同类栏目
    · Sql Server  · MySql
    · Access  · ORACLE
    · SyBase  · 其他
    更多内容
    热门推荐 更多内容
  • 没有教程
  • 赞助链接
    更多内容
    闵涛博文 更多关于武汉SEO的内容
    500 - 内部服务器错误。

    500 - 内部服务器错误。

    您查找的资源存在问题,因而无法显示。

    | 设为首页 |加入收藏 | 联系站长 | 友情链接 | 版权申明 | 广告服务
    MinTao学以致用网

    Copyright @ 2007-2012 敏韬网(敏而好学,文韬武略--MinTao.Net)(学习笔记) Inc All Rights Reserved.
    闵涛 投放广告、内容合作请Q我! E_mail:admin@mintao.net(欢迎提供学习资源)

    站长:MinTao ICP备案号:鄂ICP备11006601号-18

    闵涛站盟:医药大全-武穴网A打造BCD……
    咸宁网络警察报警平台