sqlplus - Pass parameters in a sql script via java -
i have sqlplus script requries external parameters. parameters should come array present in java code. want pass values sql script don't know how. please guide me.
my sqlplus file shown below
set echo off set heading off set feedback off set verify off set define on set trimspool on set newpage none set termout off spool &3/&2..&1..fn select text dba_source name = '&2' , type = 'function' , owner = '&1' order line / spool off exit;
the java code using execute file in unix server shown below.
try { string line; process p = runtime.getruntime().exec( "sqlplus -l user/pwd@sid @" + sqlfilepath); bufferedreader input = new bufferedreader(new inputstreamreader( p.getinputstream())); while ((line = input.readline()) != null) { system.out.println(line); } input.close(); p.destroy(); } catch (exception err) { err.printstacktrace(); }
please guide me how can pass string present in java code execute sqlplus script in unix server.
try using template engine http://freemarker.org/. generic, should not difficult use.
Comments
Post a Comment