Execute stored procedure : CallableStatement « Database SQL JDBC « Java






Execute stored procedure

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

public class Main {
  static String url = "jdbc:oracle:thin:@localhost:1521:javaDemo";
  static String username = "username";
  static String password = "welcome";
  public static void main(String[] args) throws Exception {
    Class.forName("oracle.jdbc.driver.OracleDriver");
    Connection conn = DriverManager.getConnection(url, username, password);

    CallableStatement stmt = conn.prepareCall("{call CREATE_USERS (?, ?, ?, ?, ?, ?)}");

    stmt.setString(1, "a");
    stmt.setString(2, "b");
    stmt.setString(3, "c");
    stmt.setString(4, "d");
    stmt.setString(5, "e");
    stmt.setString(6, "f");
    stmt.execute();
    conn.close();
  }
} 

   
    
  








Related examples in the same category

1.Use CallableStmts to call a stored procedure