Stored Procedure accepts two IN parameters and does not return any value. - Java JDBC

Java examples for JDBC:Stored Procedure

Description

Stored Procedure accepts two IN parameters and does not return any value.

Demo Code

import java.sql.CallableStatement;
import java.sql.Connection;

public class Main {
  public static void main(String[] args) {
    try {/*from  w  w  w. ja v  a  2  s .  c  om*/
      Connection conn = null;//JDBCUtil.getConnection();
      String sql = "{call give_raise(?, ?)}";
      CallableStatement cstmt = conn.prepareCall(sql);

      // Set the value for person_id parameter at index 1
      cstmt.setInt(1, 101);

      // Set the value for raise parameter at index 2
      cstmt.setDouble(2, 4.5);

      // Execute the stored procedure
      cstmt.execute();

    } catch (Exception e) {
      e.printStackTrace();
    }
  }
}

Result


Related Tutorials