PL/SQL Procedure Calling Java Host Command Problem

This is my first post to this forum so I hope I have chosen the correct one for my problem. I have copied a java procedure to call Unix OS commands from within a PL/SQL procedure. This java works well for some OS commands (Eg ls -la) however it fails when I call others (eg env). Can anyone please give me some help or pointers?
The java is owned by sys and it looks like this
CREATE OR REPLACE AND COMPILE JAVA SOURCE NAMED "ExecCmd" AS
//ExecCmd.java
import java.io.*;
import java.util.*;
//import java.util.ArrayList;
public class ExecCmd {
static public String[] runCommand(String cmd)
throws IOException {
// set up list to capture command output lines
ArrayList list = new ArrayList();
// start command running
System.out.println("OS Command is: "+cmd);
Process proc = Runtime.getRuntime().exec(cmd);
// get command's output stream and
// put a buffered reader input stream on it
InputStream istr = proc.getInputStream();
BufferedReader br = new BufferedReader(new InputStreamReader(istr));
// read output lines from command
String str;
while ((str = br.readLine()) != null)
list.add(str);
// wait for command to terminate
try {
proc.waitFor();
catch (InterruptedException e) {
System.err.println("process was interrupted");
// check its exit value
if (proc.exitValue() != 0)
System.err.println("exit value was non-zero: "+proc.exitValue());
// close stream
br.close();
// return list of strings to caller
return (String[])list.toArray(new String[0]);
public static void main(String args[]) throws IOException {
try {
// run a command
String outlist[] = runCommand(args[0]);
for (int i = 0; i < outlist.length; i++)
System.out.println(outlist);
catch (IOException e) {
System.err.println(e);
The PL/SQL looks like so:
CREATE or REPLACE PROCEDURE RunExecCmd(Command IN STRING) AS
LANGUAGE JAVA NAME 'ExecCmd.main(java.lang.String[])';
I have granted the following permissions to a user who wishes to run the code:
drop public synonym RunExecCmd
create public synonym RunExecCmd for RunExecCmd
grant execute on RunExecCmd to FRED
grant javasyspriv to FRED;
Execute dbms_java.grant_permission('FRED','java.io.FilePermission','/bin/env','execute');
commit
Execute dbms_java.grant_permission('FRED','java.io.FilePermission','/opt/oracle/live/9.0.1/dbs/*','read, write, execute');
commit
The following test harness has been used:
Set Serverout On size 1000000;
call dbms_java.set_output(1000000);
execute RunExecCmd('/bin/ls -la');
execute RunExecCmd('/bin/env');
The output is as follows:
SQL> Set Serverout On size 1000000;
SQL> call dbms_java.set_output(1000000);
Call completed.
SQL> execute RunExecCmd('/bin/ls -la');
OS Command is: /bin/ls -la
total 16522
drwxrwxr-x 2 ora9sys dba 1024 Oct 18 09:46 .
drwxrwxr-x 53 ora9sys dba 1024 Aug 13 09:09 ..
-rw-r--r-- 1 ora9sys dba 40 Sep 3 11:35 afiedt.buf
-rw-r--r-- 1 ora9sys dba 51 Sep 3 09:52 bern1.sql
PL/SQL procedure successfully completed.
SQL> execute RunExecCmd('/bin/env');
OS Command is: /bin/env
exit value was non-zero: 127
PL/SQL procedure successfully completed.
Both commands do work when called from the OS command line.
Any help or assistance would be really appreciated.
Regards,
Bernard.

Kamal,
Thanks for that. I have tried to use getErrorStream and it does give me more info. It appears that some of the commands cannot be found. I suspected that this was the case but I am not sure about how this can be as they all appear to reside in the same directory with the same permissions.
What is more confusing is output like so:
SQL> Set Serverout On size 1000000;
SQL> call dbms_java.set_output(1000000);
Call completed.
SQL> execute RunExecCmd('/usr/bin/id');
OS Command is: /usr/bin/id
exit value was non-zero: 1
id: invalid user name: ""
PL/SQL procedure successfully completed.
SQL> execute RunExecCmd('/usr/bin/which id');
OS Command is: /usr/bin/which id
/usr/bin/id
PL/SQL procedure successfully completed.
Regards,
Bernard

Similar Messages

  • Calling java host command in trigger/PLSQL

    I created a java call to execute a linux host command that calls a shell script that will echo out a result. It is owned by SYS and has granted execute to SYSTEM. SYSTEM has a table that monitors accesses to the RDBMS. When a user logs on from a remote server vis sqlplus, this LOGON trigger write to the SYSTEM table (successfully). SYSTEM has a trigger that runs a linux command to execute a shell script that pulls the actual IP address from the remote system. I can run this call from a PLSQL block (outside the trigger) and get a response back like "user:101.101.101.111" but when I have the same user log on, the trigger fires - no errors or exceptions yet no rows are returned. Is there some restriction in a trigger versus just a plsql block call? The java code used is what I found on (http://www.oracle-base.com/articles/8i/ ... mPLSQL.php) and it works perfectly OUTSIDE the trigger but nothing is returned in the trigger firing steps. Any idea?
    rdbms: 11.1.0.7, Redhat 4
    I know the code works because I can write the host command output to a file. Later in the trigger I can open the file and can read the data that should have been returned in the java host call.

    FYI - here is the code from your site that I used:
    DROP JAVA SOURCE SYS."Host";
    CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED SYS."Host" as import java.io.*;
    public class Host {
    public static void executeCommand(String command) {
    try {
    String[] finalCommand;
    if (isWindows()) {
    finalCommand = new String[4];
    // Use the appropriate path for your windows version.
    finalCommand[0] = "C:\\windows\\system32\\cmd.exe"; // Windows XP/2003
    //finalCommand[0] = "C:\\winnt\\system32\\cmd.exe"; // Windows NT/2000
    finalCommand[1] = "/y";
    finalCommand[2] = "/c";
    finalCommand[3] = command;
    else {
    finalCommand = new String[3];
    finalCommand[0] = "/bin/sh";
    finalCommand[1] = "-c";
    finalCommand[2] = command;
    final Process pr = Runtime.getRuntime().exec(finalCommand);
    pr.waitFor();
    new Thread(new Runnable(){
    public void run() {
    BufferedReader br_in = null;
    try {
    br_in = new BufferedReader(new InputStreamReader(pr.getInputStream()));
    String buff = null;
    while ((buff = br_in.readLine()) != null) {
    System.out.println("Cmd results: " + buff);
    try {Thread.sleep(100); } catch(Exception e) {}
    br_in.close();
    catch (IOException ioe) {
    System.out.println("Exception caught printing process output.");
    ioe.printStackTrace();
    finally {
    try {
    br_in.close();
    } catch (Exception ex) {}
    }).start();
    new Thread(new Runnable(){
    public void run() {
    BufferedReader br_err = null;
    try {
    br_err = new BufferedReader(new InputStreamReader(pr.getErrorStream()));
    String buff = null;
    while ((buff = br_err.readLine()) != null) {
    System.out.println("Cmd Error: " + buff);
    try {Thread.sleep(100); } catch(Exception e) {}
    br_err.close();
    catch (IOException ioe) {
    System.out.println("Exception caught printing process error.");
    ioe.printStackTrace();
    finally {
    try {
    br_err.close();
    } catch (Exception ex) {}
    }).start();
    catch (Exception ex) {
    System.out.println(ex.getLocalizedMessage());
    public static boolean isWindows() {
    if (System.getProperty("os.name").toLowerCase().indexOf("windows") != -1)
    return true;
    else
    return false;
    /

  • Send Datetime2 value to a SQL Procedure from Java using Hibernate

    Hi All,
    I Have a Procedure which takes a parameter of type datetime2.
    The procedure is called from Java Hibernate.
    How can I Pass datetime2 value to SQL procedure from Java?
    Thanks in advance,
    Shraddha Gore

    You may define a global empty array in some package. Then you can do:
    SQL> CREATE OR REPLACE PACKAGE pkg
    AS
       g_empty   DBMS_SQL.varchar2_table;
    END pkg;
    Package created.
    SQL> CREATE OR REPLACE PROCEDURE p (
       p_tuids   IN   DBMS_SQL.varchar2_table "DEFAULT pkg.g_empty"
    AS
    BEGIN
       NULL;
    END p;
    Procedure created.
    SQL> BEGIN
       p ();
    END;
    PL/SQL procedure successfully completed.

  • PL/SQL Procedure and Java

    Hi All,
    I am working on a Data Warehousing Product and generating Web Reports.
    These Web Reports are JSPs.
    The basic architechture used for this is :
    1. Get the inputs required for Report Generation through a Web GUI
    2. Validate and Process (If Valid) the inputs so that it can be applied on the Data in the DB to fetch appropriate information.
    3. The Data from the DB is retreived in the form of PL/SQL Procedures, which take the Processed information from Step 2 as Input and give the Output in the form of REF CURSORS.
    Note: There are a many PL/SQL Procedures that are being executed, based on the configuration the Client has set. This configuration enables the Client to set the columns he wants to see in the Web Reports. This configuration is set before the Reports are run.
    4. A call is made from Java to Oracle, each time a PL/SQL Procedure need to be executed. The REF CURSOR received as an Output from the PL/SQL Procedure is processed.
    5. The next PL/SQL Procedure is called (if existing), else the Processed Data (from REF CURSOR Output) is displayed in the JSP as Web Reports.
    The issue with above architechture is the PERFORMANCE.
    I would like to know:
    - The various ways in which data can be EFFICIENTLY & QUICKLY retrieved from PL/SQL Procedure in Java.
    - Are there any APIs that improve the Java-Oracle Data Fetch Efficiency
    - Is there any Java Framework available that can be used to increase the spped of Web Report generation.
    - Do you suggest any changes in the above mentioned architechture, that make this work a Sweet Sixeen Year olg guy! ;)
    - In general, any input that can increase the Speed of Web Report Generation.
    Kindly let me know if I have not been clear at any point, so that I can re-explain the same more clearly.
    And the most important thing, kindly scrap down your thoughts about the same.
    Thanks a lot in advance for your VALUABLE INPUTS.
    - Vikas

    Spring
    http://www.springframework.org/
    http://static.springframework.org/spring/docs/2.0.x/reference/jdbc.html
    http://static.springframework.org/spring/docs/2.0.x/reference/jdbc.html#jdbc-StoredProcedure

  • Not able to create Oracle External Procedure to Run Host Commands

    Trying to follow this article
    http://timarcher.com/node/9
    Its related to
    Oracle External Procedure to Run Host Commands
    steps
    1)mkdir –p /u01/app/usfapp/oracle_external_procs/oracle_host
    2)
    Author is suggesting to create a file
    but header file is missing in very first line... may be not sure..say it is <stdio.h>Create a file named oracle_host.c. The contents of this file will be:
    #include
    int RunCmd(char *cmd)
    return(system(cmd));
    4) Create the file named makefile. The contents of this file will be:
    oracle_host: oracle_host.o
    gcc -shared -o oracle_host.so oracle_host.o
    $ cat makefile
    oracle_host: oracle_host.o
         gcc -shared -o oracle_host.so oracle_host.o
    5)
    Now run the command make
    The output on my server looks like:
    [u01/app/usfapp/oracle_external_procs/oracle_host]
    banner@usfbannerte [TRNG] > make
    gcc -shared -o oracle_host.so oracle_host.o
    here I stuck .. Not able to run this step ]$ make
    gcc -shared -o oracle_host.so oracle_host.o
    /usr/bin/ld: oracle_host.o: relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC
    oracle_host.o: could not read symbols: Bad value
    collect2: ld returned 1 exit status
    make: *** [oracle_host] Error 1
    Any one has any idea what went wrong
    Any other link related to this is most welcomed.
    Please suggest ...

    hi
    please update
    or
    provide any other link / document for
    Oracle External Procedure to Run Host Commands
    --using c
    Thanks in advance.

  • Calling a Host Command

    Dear Friends,
    Is it posible to call a host command (windows) from PLSQL (Oracle 9i) ?
    Thanks.
    Jai

    > [email protected]
    [email protected]
    [email protected]
    So.. the one who dies with the most e-mail addresses wins?
    Or what exactly is the purpose of posting all your e-mail addresses - besides as food for web bot e-mail harvesters used by spammers?

  • How to call a host command/program within a PL/SQL Procedure OR Block

    Hello ,
    I want to call a host program (in my case it is unix shell program) from within a PL/SQL
    Procedure..Please let me know if you have a clue...Thanks a bunch...Ajeet

    Alternatively you could create a PL/SQL procedure that wraps a Java Runtime object.
    You can find an example of this in the Ask Tom column of Oracle Magazine. You can get there from OTN home page. Type "Java Runtime" into the Search Archive engine.
    HTH, APC

  • Jdbc NullPointerException calling pl/sql procedure from java

    Hi.
    Getting the following exception calling a plsql procedure from jdbc.
    - Jdbc version is 10.2.0.2, but it also happens running several other variants, including 10.1.0.5.0.
    - Application is running in Weblogic 8.1.3 (8.1 SP 3).
    The procedure call itself has 2 in/out parameters which are tables (actually just 1 dimensional arrays), which I'm suspecting has something to do with the problem. I can successfully call this procedure using a plsql developer tool with the same bind parameters.
    Any ideas?
    Exception encountered while executing PL/SQL procedure MVT_Web_Inquiry.ShowInquiry:
    java.lang.NullPointerException at oracle.jdbc.driver.T4CTTIiov.processRXD([Loracle.jdbc.driver.Accessor;I[B[C[SILoracle.jdbc.driver.DBConversion;[B[B[[Ljava.io.InputStream;[[[B[[Loracle.jdbc.oracore.OracleTypeADT;Loracle.jdbc.driver.OracleStatement;[B[C[S)[Loracle.jdbc.driver.Accessor;(T4CTTIiov.java:139)
    at oracle.jdbc.driver.T4C8Oall.receive()V(T4C8Oall.java:521)
    at oracle.jdbc.driver.T4CCallableStatement.doOall8(ZZZZ)V(T4CCallableStatement.java:215)
    at oracle.jdbc.driver.T4CCallableStatement.executeForRows(Z)V(T4CCallableStatement.java:1119)
    at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout()V(OracleStatement.java:1278)
    at oracle.jdbc.driver.OraclePreparedStatement.executeInternal()I(OraclePreparedStatement.java:3446)
    at oracle.jdbc.driver.OraclePreparedStatement.execute()Z(OraclePreparedStatement.java:3552)
    at oracle.jdbc.driver.OracleCallableStatement.execute()Z(OracleCallableStatement.java:5261)
    at weblogic.jdbc.wrapper.PreparedStatement.execute()Z(PreparedStatement.java:70)
    at
    [snip]

    OK... I figured it out.
    Apparently, this error happens when you forget to register the output part of an in/out parameter. I would have hoped for better error messaging, but oh well.
    -ed-

  • Calling PL/SQL Procedures from Java

    Hello,
    I want to know, if it is possible to call PL/SQL Procedures from
    SQLJ(which uses htp.print from the Package web toolkit ).
    Though, it is possible to call normal procedures but if I want
    to call PL/SQL procedures with htp.print then I get I error.
    For example:
    #sql{Call html_test()};
    Can you give me a advice?
    Your help is much appreciated!
    M|ller

    Oracle's htp packages are develop to be work with
    mod_plsql/OAS/OWS webserver.
    If you are trying to use htp packages first need to instanciate
    some enviroment vars for htp packages, for example first you has
    to call to owa.initialize procedure, populate owa.cgi array and
    so on.
    If you need more information about how this toolkit works you
    could get the source of DB Prism at
    http://www.plenix.com/dbprism/ this open source framework
    includes backward compatibility with mod_plsql application and
    then includes settings of this values from Java code.
    Best regards, Marcelo.

  • Host Command Problem

    hi,
    I'm running on OpenVMS 7.2-1 (no unix in this shop) trying to get the HOST command to return status. In desperation I created a dummy form with 1 button that when pressed issues:
    HOST('lalala');
    if not form_success then
    message ('bad status returned');
    else message ('good status returned');
    end if;
    Form_Status always returns success, even for totally bogus commands (like 'lalala'). I've put the test_cmd into a varchar2 in the pl/sql, I've put it in a dummy.com file then had the host file call dummy.com... I can't get anything except a successful status to return. What's up. That's what all the ora docs say to do. Any hints?
    thanks
    Sandy

    (2nd try. 404 on 1st reply)
    I would agree that the form is behaving as though it never sees the OS error.
    I tried both w/ & w/o no-screen and the results back to the form are the same (form_success = true), however w/o no-screen at least displays on the os cmd line the error.
    I tried tool_env.getvar returning '$status' returns blank.
    My form calls host('@dummy.com') where dummy.com does "exit $status". Show symbol $status does show an error but the form is not getting it.
    sg

  • Passing parameters to pl/sql procedure called in portal

    Hi all,
    I am trying to use a javascript window.open function to create a small popup window that is populated by a pl/sql procedure from inside portal.
    I am trying to pass it a parameter to refine a SQL query running in that procedure, unfortunately I'm not sure of the syntax. The url that I'm trying to open in the new window looks like this:
    http://my.server.com:7777/portal/pls/portal/myschema.mypackage.myprocedure
    If I just run this, it works fine and the popup window opens correctly and displays all results. If I try to pass a parameter, it errors out with a 404 Page Not Found.
    The parameter itself comes from a text field that the user can enter a value into. I am able to get the value of that text field and append it to the url I'm generating, but I can't find the proper syntax.
    I've tried numerous syntax variants, but none of them seem to work. The procedure does have the parameter defined in both the spec and body and properly handles it. Can anyone point me in the right direction?
    Thanks,
    -Mike Markiw

    You said you have a text field where a user enters a value, so I am assuming that you have form...
    you can try following
    <form action="/pls/portal/myschema.mypackage.myprocedure" method="post">
    your text field "inVar"
    your submit button
    </form>
    I am sure your myprocedure has inVar as an input...
    If you just want to pass a value to a procedure you can always do following:
    http://my.server.com:7777/portal/pls/portal/myschema.mypackage.myprocedure?inVar=the value

  • Bug calling PL/SQL procedure from Java

    Has anybody encountered this problem/know the solution to the following problem?
    I have a collection of Java Beans that call the database (8.1.6). The code works perfectly except when done through a user on the DB who only has permissions to execute the PL/SQL code defined by another user AND when I use the thin drivers.. using OCI works a treat.
    The error appears to be a security exception saying that no table or view was found 'ORA-00942: table or view does not exist'..
    This does not happen for all of the procedures, only the ones that return ref cursors.
    This code worked fine on Oracle8, the problem is limited to 8i and thin drivers.
    Any suggestions as to what the problem could be/confirmation that it is a bug with Oracle would be appriciated.
    Thanx,
    - Chris.
    Brainbench MVP Java2.

    I have seen this behavior too. Oracle, could you please respond on this one.
    Thanks

  • Unable to call a pl/sql procedure from java

    Software : Oracle 9i & Red hat linux 9
    Code:
    import java.io.*;
    import java.sql.*;
    public class test
    public static void main(String args[])
    try
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    Connection con=DriverManager.getConnection("jdbc:oracle:thin:@192.168.0.221:1521:elearn","gowri","gowri");
    CallableStatement call=con.prepareCall("{call ins(?,?,?,?)}");
    call.setInt(1,5);
    call.setString(2,"hari");
    call.setString(3,"m");
    call.setString(4,"1976-12-26");
    if ( call.execute() )
    System.out.println("Success");
    else
    System.out.println("fails");
    call.close();
    con.close();
    catch(Exception ex)
    System.out.println("Error :"+ex);
    ~
    ~
    ~
    Stored Procedure:
    create or replace procedure ins(no in number,name in varchar,sex in varchar,dob in varchar)is
    con_day date;
    begin
    con_day=to_date(dob,'yyyy-mm-dd');
    insert into person values(no,name,sex,con_day);
    end;
    Run Time Error:
    Exception in thread "main" java.lang.IncompatibleClassChangeError: oracle.jdbc.driver.OraclePreparedStatement
    at 0x40268e17: java.lang.Throwable.Throwable(java.lang.String) (/usr/lib/./libgcj.so.3)
    at 0x4025bc8e: java.lang.Error.Error(java.lang.String) (/usr/lib/./libgcj.so.3)
    at 0x4025d6b6: java.lang.LinkageError.LinkageError(java.lang.String) (/usr/lib/./libgcj.so.3)
    at 0x4025c7aa: java.lang.IncompatibleClassChangeError.IncompatibleClassChangeError(java.lang.String) (/usr/lib/./libgcj.so.3)
    at 0x40229eed: JvPrepareClass(java.lang.Class) (/usr/lib/./libgcj.so.3)
    at 0x40248028: java.lang.ClassLoader.linkClass0(java.lang.Class) (/usr/lib/./libgcj.so.3)
    at 0x4025acb3: java.lang.ClassLoader.resolveClass0(java.lang.Class) (/usr/lib/./libgcj.so.3)
    at 0x402299cb: JvPrepareClass(java.lang.Class) (/usr/lib/./libgcj.so.3)
    at 0x40248028: java.lang.ClassLoader.linkClass0(java.lang.Class) (/usr/lib/./libgcj.so.3)
    at 0x4025acb3: java.lang.ClassLoader.resolveClass0(java.lang.Class) (/usr/lib/./libgcj.so.3)
    at 0x4024646c: java.lang.Class.initializeClass() (/usr/lib/./libgcj.so.3)
    at 0x40230912: JvInterpMethod.continue1(_Jv_InterpMethodInvocation) (/usr/lib/./libgcj.so.3)
    at 0x40230ff4: JvInterpMethod.run(ffi_cif, void, ffi_raw, JvInterpMethodInvocation) (/usr/lib/./libgcj.so.3)
    at 0x4022e504: JvInterpMethod.run_normal(ffi_cif, void, ffi_raw, void) (/usr/lib/./libgcj.so.3)
    at 0x4038305c: ?? (??:0)
    at 0x403831e7: ffi_call_SYSV (/usr/lib/./libgcj.so.3)
    at 0x403831a7: ffi_raw_call (/usr/lib/./libgcj.so.3)
    at 0x402306e8: JvInterpMethod.continue1(_Jv_InterpMethodInvocation) (/usr/lib/./libgcj.so.3)
    at 0x40230ff4: JvInterpMethod.run(ffi_cif, void, ffi_raw, JvInterpMethodInvocation) (/usr/lib/./libgcj.so.3)
    at 0x4022e58a: JvInterpMethod.run_synch_object(ffi_cif, void, ffi_raw, void) (/usr/lib/./libgcj.so.3)
    at 0x4038305c: ?? (??:0)
    at 0x403831e7: ffi_call_SYSV (/usr/lib/./libgcj.so.3)
    at 0x403831a7: ffi_raw_call (/usr/lib/./libgcj.so.3)
    at 0x402306e8: JvInterpMethod.continue1(_Jv_InterpMethodInvocation) (/usr/lib/./libgcj.so.3)
    at 0x40230ff4: JvInterpMethod.run(ffi_cif, void, ffi_raw, JvInterpMethodInvocation) (/usr/lib/./libgcj.so.3)
    at 0x4022e504: JvInterpMethod.run_normal(ffi_cif, void, ffi_raw, void) (/usr/lib/./libgcj.so.3)
    at 0x4038305c: ?? (??:0)
    at 0x40242dd8: gnu.gcj.runtime.FirstThread.call_main() (/usr/lib/./libgcj.so.3)
    at 0x402ad02d: gnu.gcj.runtime.FirstThread.run() (/usr/lib/./libgcj.so.3)
    at 0x4024fc4c: JvThreadRun(java.lang.Thread) (/usr/lib/./libgcj.so.3)
    at 0x4021c8ac: JvRunMain(java.lang.Class, byte const, int, byte const, boolean) (/usr/lib/./libgcj.so.3)
    at 0x08048910: ?? (??:0)
    at 0x42015574: __libc_start_main (/lib/tls/libc.so.6)
    at 0x080486c1: ?? (??:0)

    Hi Gowrishankar,
    This is just a suggestion (based on a guess). Try changing this line of your code:
    call.setInt(1,5);with this line:
    call.setBigDecimal(1,5);Good Luck,
    Avi.

  • Execute a sql procedure with java?

    Hi
    Got this CREATE OR REPLACE PROCEDURE legg_til_student (p_fnavn student.fornavn%TYPE, p_enavn student.etternavn%TYPE, p_klasseid student.klasseid%TYPE) IS
    v_id student.id%TYPE;
    BEGIN
         SELECT MAX(id) +1 INTO v_id
         FROM student;     
         IF p_klasseid > 3 THEN
         DBMS_OUTPUT.PUT_LINE ('Ugyldig klasseid');
         ELSE
         INSERT INTO student VALUES (v_id, p_fnavn, p_enavn, p_klasseid);
         END IF;
    END;
    /  Procedure that are mad in sql+ , the problem is how to run this trough java ?
    Thanks :)

    Hey I wrote this :
    public void registrerStudent(StudentVO student) {
              Connection con = null;
              CallableStatement proc;
              try {
                   proc = con.prepareCall("{call legg_til_student(?, ?) }");
                   proc.setString(1, student.finnFornavn());
                   proc.setString(2, student.finnEtternavn());
                   proc.setInt(3, student.finnKlasse());
                   proc.execute();
                   proc.close();
              } catch (SQLException e) {
                   System.out.println("BLEHHH");
                   e.printStackTrace();
         }And Testing with this class :
    public class Test {
         public static void main(String args[]){
              StudentDAO dao = new StudentDAO();
              StudentVO t = new StudentVO("Arne", "Nilsen", 3);
              dao.registrerStudent(t);
    }But i am getting a
    java.lang.NullPointerException
         at ver002.student.StudentDAO.registrerStudent(StudentDAO.java:44)
         at ver002.student.Test.main(Test.java:22)
    Exception in thread "main" Any idea what i am doing wrong ?

  • MS SQL Procedure Call from Oracle Database

    I have Oracle Database 11g connected to MS Sql Server 2008 via dg4msql, and need to execute procedure on MS Sql with parameters from Oracle, and get dataset (table) as a result.
    I'm not sure is it possible to call procedure directly from Oracle; One solution would be make function on MS SQL, and put select on procedure from Oracle, but what with parameters?
    Is there some possibility to call this procedure from Oracle and get this dataset as a cursor?
    Thanks in advance!
    Edited by: mihaelradovan on 2012.04.26 14:35

    Yes, of course I have DB Link in Oracle and procedure in SQL Server.
    Btw, I can select data from SQL Server table.
    I made one function in SQL Server, and I can not make select on this function, but in SQL Server I made view as select * from function_name, and select on this view from Oracle works. But problem is I have to call this procedure or function with parameters, and with view I can not do this.
    So, I must call procedure or function with parameters directly. I made all by the book (Oracle® Database Gateway for SQL Server User’s Guide), but probably I miss something...

Maybe you are looking for

  • Using Bean Attributes in a JSP for a h:commandLink

    Hi, I am very new to JSF so apologies if the answer is obvious. I currently have a ArrayList of products obtained from a database. Using... <h:dataTable value="#{ProductBean.productList}" var="product">                 <h:column>                    

  • Youtube and Vimeo Share Fails

    Sharing to Youtube and Vimeo fails with no explanation on my i7 MacBook Pro. 3 minute sequence, sorry "project"

  • Upgradation  of 11g database R1 to R2

    Hi Currently we are on 11g database R1 and we want to upgrade to R2 soon.Please let me know the steps on how to do this.Is there any patch that we need to update on 11g database R2.Is there any document which lists all the instructions for upgradatio

  • Credit card processing is temp. unavailable.

    Hey. I just got a new itouch today, and tried downloading an app. it asked me to fill in my account info, including my payment method. First it said the security code was wrong, which it wasnt, then, it started telling me "Credit card processing is t

  • Actions calling methods?

    Alright, so what you see below is a piece of my attempt to pop up a gui after having parsed a word file. In this word file, there are variables being defined, and i am trying to use this code to replace some of the variables that have been hard coded