Results 1 to 4 of 4
  1. #1
    mew
    mew is offline Member
    Join Date
    Nov 2007
    Posts
    70
    Rep Power
    0

    Default Executing stored procedures

    I want to execute a stored procedure on MS SQL Sever 2000 using Java. The stored procedure returns multiple records. How is this possible.

  2. #2
    rico16135 is offline Member
    Join Date
    Apr 2008
    Posts
    28
    Rep Power
    0

    Default

    Try a PreparedStatement, ResultSet

  3. #3
    rico16135 is offline Member
    Join Date
    Apr 2008
    Posts
    28
    Rep Power
    0

    Default

    sry that compiles a statement, try this link:

    ONJava.com -- Stored Procedures for Java Programmers

  4. #4
    herfnai is offline Member
    Join Date
    Aug 2008
    Posts
    13
    Rep Power
    0

    Default

    hello:

    syntax:
    {call procedure_name[(?, ?, ...)]}
    The syntax for a procedure that returns a result parameter is:
    {? = call procedure_name[(?, ?, ...)]}
    The syntax for a stored procedure with no parameters would look like this:
    {call procedure_name}


    CallableStatement cstmt = con.prepareCall(
    “{call getTestData(?, ?)}”);
    cstmt.registerOutParameter(1, java.sql.Types.TINYINT);
    cstmt.registerOutParameter(2, java.sql.Types.DECIMAL, 3);
    cstmt.executeQuery();
    byte x = cstmt.getByte(1);
    java.math.BigDecimal n = cstmt.getBigDecimal(2, 3);

    CallableStatement cstmt = con.prepareCall(
    “{call reviseTotal(?)}”);
    cstmt.setByte(1, 25);
    cstmt.registerOutParameter(1, java.sql.Types.TINYINT);
    cstmt.executeUpdate();
    byte x = cstmt.getByte(1);

Similar Threads

  1. Stored Procedures
    By geeta_ravikanti in forum JDBC
    Replies: 1
    Last Post: 04-22-2008, 03:34 AM
  2. Calling SQL Server stored procedures
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-07-2008, 09:40 AM
  3. Stored Procedures with java
    By Albert in forum JDBC
    Replies: 4
    Last Post: 06-08-2007, 06:59 AM
  4. stored procedures in Hibernate
    By Alan in forum JDBC
    Replies: 2
    Last Post: 05-31-2007, 05:49 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
  •