• <bdo id='35v61'></bdo><ul id='35v61'></ul>
  1. <tfoot id='35v61'></tfoot>
  2. <small id='35v61'></small><noframes id='35v61'>

    <legend id='35v61'><style id='35v61'><dir id='35v61'><q id='35v61'></q></dir></style></legend>
    <i id='35v61'><tr id='35v61'><dt id='35v61'><q id='35v61'><span id='35v61'><b id='35v61'><form id='35v61'><ins id='35v61'></ins><ul id='35v61'></ul><sub id='35v61'></sub></form><legend id='35v61'></legend><bdo id='35v61'><pre id='35v61'><center id='35v61'></center></pre></bdo></b><th id='35v61'></th></span></q></dt></tr></i><div id='35v61'><tfoot id='35v61'></tfoot><dl id='35v61'><fieldset id='35v61'></fieldset></dl></div>

    1. 用于检查数据库(连接)是否存在的 Ant 任务?

      时间:2023-08-21

      • <i id='swfDU'><tr id='swfDU'><dt id='swfDU'><q id='swfDU'><span id='swfDU'><b id='swfDU'><form id='swfDU'><ins id='swfDU'></ins><ul id='swfDU'></ul><sub id='swfDU'></sub></form><legend id='swfDU'></legend><bdo id='swfDU'><pre id='swfDU'><center id='swfDU'></center></pre></bdo></b><th id='swfDU'></th></span></q></dt></tr></i><div id='swfDU'><tfoot id='swfDU'></tfoot><dl id='swfDU'><fieldset id='swfDU'></fieldset></dl></div>
        <legend id='swfDU'><style id='swfDU'><dir id='swfDU'><q id='swfDU'></q></dir></style></legend>

        <small id='swfDU'></small><noframes id='swfDU'>

          • <bdo id='swfDU'></bdo><ul id='swfDU'></ul>
              <tbody id='swfDU'></tbody>

              <tfoot id='swfDU'></tfoot>
                本文介绍了用于检查数据库(连接)是否存在的 Ant 任务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                在 ANT 中是否有可能在不导致构建失败的情况下检查数据库(连接)是否存在?

                is there a possibility in ANT to check whether a database (connection) exists or not without failing the build?

                例如:

                <target name="check-database-available">
                    <sql
                        classpath="${oracle.jar}" driver="oracle.jdbc.OracleDriver"
                        url="jdbc:oracle:thin:@${my.db.host}:${my.db.port}:${my.db.sid}" 
                        userid="${my.db.user}" 
                        password="${my.db.pw}"
                        onerror="continue" errorproperty="exit.status">
                        select * from dual;
                    </sql>
                    <echo message="### exit status = ${exit.status}" />
                </target>
                

                这将始终失败并显示 BUILD FAILED 和

                This will always fail with BUILD FAILED and

                java.sql.SQLException: ORA-01017: invalid username/password; logon denied
                

                因为数据库还不存在.将onerror"设置为continue"并检查errorproperty"将不起作用,因为任务似乎没有被执行.

                because the db does not exist yet. Setting "onerror" to "continue" and checking the "errorproperty" won't work as the task seems not to be executed.

                推荐答案

                这是一个设置 db.present 属性的解决方法(checkpresence.sql 是一个简单的选择语句)

                Here is a workaround which sets a db.present property (checkpresence.sql is a simple select statement)

                <target name="check-db-presence">
                  <echo message="Checking database presence at: ${db.url}"/>
                  <delete file="tmp/db.present"/>
                  <sql driver="${db.driver}" url="${db.url}"
                                     userid="${db.userName}" password="${db.password}"
                                     failOnConnectionError="false" onerror="continue" warningproperty="db.empty" errorproperty="db.empty" 
                                      src="scripts/${db.platform}/checkpresence.sql"
                                    print="true" output="tmp/db.present"/>
                  <condition property="db.present">
                    <available file="tmp/db.present"/>
                  </condition>
                </target>
                

                这篇关于用于检查数据库(连接)是否存在的 Ant 任务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:MySql 中的 DELIMITER 错误 下一篇:如何在 MySQL 中可靠地删除和创建数据库和用户

                相关文章

                最新文章

                <small id='tYiDJ'></small><noframes id='tYiDJ'>

                <i id='tYiDJ'><tr id='tYiDJ'><dt id='tYiDJ'><q id='tYiDJ'><span id='tYiDJ'><b id='tYiDJ'><form id='tYiDJ'><ins id='tYiDJ'></ins><ul id='tYiDJ'></ul><sub id='tYiDJ'></sub></form><legend id='tYiDJ'></legend><bdo id='tYiDJ'><pre id='tYiDJ'><center id='tYiDJ'></center></pre></bdo></b><th id='tYiDJ'></th></span></q></dt></tr></i><div id='tYiDJ'><tfoot id='tYiDJ'></tfoot><dl id='tYiDJ'><fieldset id='tYiDJ'></fieldset></dl></div>
                  <bdo id='tYiDJ'></bdo><ul id='tYiDJ'></ul>
                  1. <legend id='tYiDJ'><style id='tYiDJ'><dir id='tYiDJ'><q id='tYiDJ'></q></dir></style></legend>

                  2. <tfoot id='tYiDJ'></tfoot>