使用Ant编译JDBC [英] Jdbc compilation using Ant

查看:176
本文介绍了使用Ant编译JDBC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用下面的ant脚本的JDBC编辑。

 < SQL驱动程序=oracle.jdbc.driver.OracleDriver
URL =的jdbc:神谕:薄:// 10.184.133.133:1521:人联党
用户id =$ {} UsernameB
密码=$ {} PasswordB
的onerror =继续
delimitertype =行
分隔符=/
keepformat =YES>

我有以下内容的文件:


  

创建或替换为CIVW代名词CIVWS;结果
  /


以上编译,出现以下错误失败。

  java.sql.SQLSyntaxErrorException:ORA-00911:无效字符

据我所知,分隔符是/,因此SQL语句后的分号造成的问题。有数百个这样的文件,都将在sqlplus正确编译。但是不能使用JDBC。我现在不能改变的code。对此有任何变通。我不能改变的分隔符;也。请建议。


解决方案

  1. 首先,你可以尝试使用 ...分隔符=; delimitertype =行... ,并确保包含PL / SQL块;被一些;分隔在同一行(只有一个换行符紧随其后 - 从而触发它的执行作为单个语句)。


  2. 如果您不能添加;手,尝试将源文件复制到一些TMP目录并尝试(例如,使用一个正则表达式蚂蚁副本任务来代替过滤器),以通过手动或自动的一些正则表达式替换有更改。
    (如更换匹配 ^(*年底\\ S *;?)(*)$ \\ 1 \\ n行;。\\ n \\ 2 如果你是幸运的可能是不够的)


  3. 用于插入另一种解决方案; - 单线分隔符可以把这些块单独的文件中(也许自动化),并通过&LT执行它们; SQL><成交SRC =< yoursqlfile> .SQL/> <!--...--> < / SQL> <!--...--方式> Ant任务


I am using the following ant script for jdbc compilations.

<sql driver="oracle.jdbc.driver.OracleDriver"
url="jdbc:oracle:thin:@10.184.133.133:1521:SUPP"
userid="${UsernameB}"
password="${PasswordB}"
onerror="continue"
delimitertype="row"
delimiter="/"
keepformat="yes">

I have a file with the following content:

create OR REPLACE synonym CIVWS for CIVW;
/

compilation of the above is failing with the following error.

java.sql.SQLSyntaxErrorException: ORA-00911: invalid character

I understand that the delimiter is / and hence the semi colon after the sql statement has caused the issue. There are hundreds of files like this, all will compile properly in sqlplus. However fail with jdbc. I cant change the code now. Is there any work around for this. I cant change the delimiter to ; also. Please suggest.

解决方案

  1. first you could try to use ... delimiter=";" delimitertype="row" ... and make sure that the pl/sql blocks containing ";"s are separated by some ";" on a single line (with only a newline following it immediately - thus triggering the execution of it as a single statement).

  2. if you can't add the ";" by hand, try to copy the source files to some tmp dir and try to change them there by hand or by some automated regexp replacement (e.g. using ant copy task with a regexp replace filter). (e.g. replacing lines matching ^(.*end\s*;?)(.*)$ by \1\n;\n\2 could be enough if you are lucky)

  3. another solution for inserting the ";"-single line delimiters could be to put these blocks in separate files (maybe automated) and execute them via the <sql><transaction src="<yoursqlfile>.sql" /> <!--...--> </sql> <!--...-->" ANT task.

这篇关于使用Ant编译JDBC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆