java 使用SQLExec执行sql文件
目前需求使用java程序直接执行sql文件,使用这种方式可以完成部分的sql,一旦遇到这样的就报错了drop sequence SEQ_RCID;
declare
StartValue integer;
begin
select nvl(max(rcid), 0)+1 into StartValue from sys_right_combination;
execute immediate '
create sequence SEQ_RCID
minvalue 1
maxvalue 99999999
start with ' || StartValue ||
' increment by 1
cache 5
cycle';
end;
----------------------------------------
SQLExec exec=new SQLExec();
exec.setDriver("oracle.jdbc.driver.OracleDriver");
exec.setUrl("jdbc:oracle:thin:@localhost:1521:orcl");
exec.setUserid("gfmis");
exec.setPassword("1");
exec.setSrc(new File("src/clearalldata.sql"));
// exec.setOnerror((SQLExec.OnError)EnumeratedAttribute.getInstance(SQLExec.class, "abort"));
exec.setOnerror((SQLExec.OnError)(EnumeratedAttribute.getInstance(
SQLExec.OnError.class, "abort")));
exec.setPrint(true);
exec.setOutput(new File("src/out.sql"));
exec.setProject(new Project());
exec.execute();