Install sqlplus and shell in Linux to query the database and download the rpm file, install orcacle sqlplus Java code rpm-ivh oracle-instantclient-basic-10.2.0.4-1.i386.rpm rpm-ivh oracle-instantclient-sqlplus-10.2.0.4-1.i386.rpm after installation is complete, you need to set the environment variable Java code LD_LIBRARY_PATH =/usr/lib/oracle/10.2.0.1/client/lib: $ {LD_LIBRARY_PATH} export LD_LIBRARY_PATH SQLPATH =/usr/lib/oracle/10.2.0.1/client/lib :$ {SQLPATH} export SQLPATH query database example using shell script: Java code #! /Bin/bash name = $1 passwd = $2 host = $3 port = $4 sid = $5 VALUE = 'sqlplus-S $ name/$ passwd @ $ host: $ port/$ sid <! Set heading off set feedback off set pagesize 0 set verify off set echo off select id from table_name; exit! '# Cataloguuid echo $ VALUE if [-n "$ VALUE"]; then echo "The rows is $ VALUE" exit 0 else echo "There is no row" fi: java code sqlplus-S $ name/$ passwd @ $ host: $ port/$ sid <!> QueryResult. out set heading off set feedback off set pagesize 0 set verify off set echo off select id from table_name; exit! '[Oracle @ hb shell_test] $ cat echo_time #! /Bin/sh 1. The simplest way to call sqlplus-S "sys/unimas as sysdba" <! Select to_char (sysdate, 'yyyy-mm-dd') today from dual; exit ;! [Oracle @ hb shell_test] $./echo_time TODAY ---------- 2011-03-21-S is the silent mode and does not output information such as "SQL>", connecting to the database, closing the database, and so on. Eof can be any string, such as "laldf". When you enter a single laldf line, "shell considers that the input is complete, but it must indicate that the block must start to use <; the start and end parameters must match the <symbol. For example: java code [oracle @ hb shell_test] $ sqlplus-s "sys/unimas as sysdba" <abc> select to_char (sysdate, 'yyyy-mm-dd ') today from dual;> exit;> abc TODAY ---------- 2011-03-21 II. method 1 of passing sqlplus results to shell Java code [oracle @ hb shell_test] $ cat test2.sh #! /Bin/bash VALUE = 'sqlplus-S "test/unimas" <! Set heading off set feedback off set pagesize 0 set verify off set echo off select to_char (sysdate, 'yyyy-mm-dd') today from dual; exit! 'Echo $ VALUE if [-n "$ VALUE"]; then echo "The rows is $ VALUE" exit 0 else echo "There is no row" fi III. method 2 of passing sqlplus results to shell Java code [oracle @ hb shell_test] $ cat test1.sh #! /Bin/bash sqlplus-S "test/unimas" <! Set heading off set feedback off set pagesize 0 set verify off set echo off col coun new_value v_coun select count (*) coun from lesson; exit v_coun! VALUE = "$? "Echo" show row: $ VALUE "col coun new_value v_coun is of the number type. Because exit can only return numerical values. 4. Pass the shell parameter to sqlplus Java code #! /Bin/bash t_id = "$1" sqlplus-S "test/unimas" <! Set heading off set feedback off set pagesize 0 set verify off set echo off select teachername from teacher where id = $ t_id; exit! 5. sqlplus results are stored in the file's Java code #! /Bin/sh sqlplus-S "test/unimas" <EOF set heading off set feedback off set pagesize 0 set verify off set echo off spool spool_file SELECT * from teacher; spool off exit; EOF