从Java运行sqlplus脚本的简单方法 [英] Simple way to run sqlplus script from java

查看:327
本文介绍了从Java运行sqlplus脚本的简单方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含sqlplus特定脚本的sql文件:它包含/或;作为语句终止符,执行存储过程的EXEC等.

I've got sql file that contains sqlplus specific script: it includes / or ; as statement terminators, EXEC to execute stored procedures, etc.

我需要从Java(jdbc)执行此脚本,而无需sqlplus.

I need to execute this script from java (jdbc) without the need for sqlplus.

sql ant任务/maven sql插件无法处理不同的终止符或EXEC命令.

sql ant task / maven sql plugin can't handle the different terminators or EXEC commands.

您知道不运行sqlplus的任何好方法吗?

Do you know any good way to do so without running sqlplus ?

推荐答案

我们遇到了同样的问题...简而言之,目前还没有现成的解决方案:如果打开

We've bumped into the same problem... In brief, there are no ready solutions for that: if you open Ant or Maven sources, you'll see they are using a simple regexp-based script splitter which is fine for simple scripts, but usually fails on e.g. stored procedures.

确实有用于PL/SQL的ANTLR解析器,例如 Alexandre Porcelli的解析器-非常接近,但仍不能用作嵌入式解决方案.

There are indeed ANTLR parsers for PL/SQL, such as Alexandre Porcelli's one—those are very close, but still not ready to be used as a drop-in solution.

我们最终编写了

We ended up writing yet another ad hoc splitter which is aware of some sqlplus commands like / and EXIT— it's still ugly, but works for most of our scripts.

这篇关于从Java运行sqlplus脚本的简单方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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