Ant SQL任务错误属性示例



有人知道如何使用SQL TASK errorproperty的例子吗?我正在尝试做这样的事情:

<sql
                driver="${jdbc.driver.class}"
                url="${jdbc.url}"
                userid="${db.admin.user}"
                password="${db.admin.password}"
                onerror="continue"
                autocommit="true"
                delimiter="/"
                print="true"
                failOnConnectionError="false"
                errorproperty="dberror">
            <classpath>
                <pathelement location="${jdbc.driver.location}"/>
            </classpath>
            ${query.drop}
        </sql>
<if>
<isset dberror>
do this
<else> 
do that
</if>

With Ant <<br>

<project>
 <target name="calldb"
  <sql .. errorproperty="dberror"/>
  <condition property="isdberror">
   <isset property="dberror"/>
  </condition>
 </target>  
  <target name="ifdberror" if="isdberror">
   ...
  </target>
  <target name="nodberror" unless="isdberror">
   ...
  </target>
  <!-- create target dependency chain -->
  <target name="whatever" depends="calldb,ifdberror,nodberror"/>
</project>

使用Ant>= 1.9.3,你可以这样做:

<project
  xmlns:if="ant:if"
  xmlns:unless="ant:unless"
>
 <target name="calldb">
  <sql .. errorproperty="dberror"/>
  <!-- example, echo instead of real work .. -->
  <echo unless:blank="${dberror}">Houston, we have a problem !!</echo>
  <echo if:blank="${dberror}">Strike :-)</echo>
 </target>
</project>

相关内容

  • 没有找到相关文章

最新更新