Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2009
    Posts
    3
    Rep Power
    0

    Default How to call Oracle stored procedure from Java?

    Hello All,

    I want to call one stored procedure from Java. I have written following code. But its not able to make connection to server where Database is running.


    Java Code:
     try
          {
      DriverManager.registerDriver (new oracle.jdbc.OracleDriver());
      Connection conn = DriverManager.getConnection ("jdbc:oracle:thin:@192.168.100.148:1526:VIS1", "apps", "apps");
      CallableStatement  cstmt        = null;
      cstmt = conn.prepareCall("Begin myproc(:1); End;");
      cstmt.setString(1,dis.readLine());
      cstmt.execute();
          }
    catch (SQLException ex) 
          {
            System.out.println("Failed to establish a connection to: ");
          }
     }
    Regards,
    Parag

  2. #2
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    It would help if you actually posted what exception you got.

  3. #3
    Join Date
    Oct 2009
    Posts
    3
    Rep Power
    0

    Default

    Its going in SQLException which I handles and showing

    "Failed to establish a connection to:

    Process exited with exit code 0."

  4. #4
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    Yes, I know that from looking at the code. I want to know what exception you are getting. Add an ex.printStackTrace() to that catch block.

  5. #5
    Join Date
    Oct 2009
    Posts
    3
    Rep Power
    0

    Default

    Great...

    ex.printStackTrace() showed me error as "Invalid number". I found that in a procedure I am inserting character value in Number column.


    Problem is solved. I am new to Java. Now I will read exceptions properly.

    Thanks a lot.

Similar Threads

  1. Replies: 2
    Last Post: 01-30-2009, 01:53 PM
  2. [SOLVED] Java equivalent to X11 Work Procedure
    By LongHitter in forum New To Java
    Replies: 0
    Last Post: 01-12-2009, 12:36 PM
  3. stored procedure
    By sankarigopi in forum JDBC
    Replies: 1
    Last Post: 11-13-2008, 05:53 PM
  4. How to get multiple rows from Stored Procedure
    By SRJ1957 in forum Advanced Java
    Replies: 0
    Last Post: 08-11-2008, 09:26 PM
  5. Replies: 0
    Last Post: 01-02-2008, 02:52 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •