//Callable Statement import java.sql.DriverManager; import java.sql.SQLException; import java.sql.CallableStatement; import java.sql.Connection; public class StatementDemo { public static void main(String[] args) { String DB_URL = "jdbc:oracle:thin:@//localhost:1521/XE"; String user = "system"; String pass = "1234"; try (Connection conn = DriverManager.getConnection(DB_URL, user, pass)) { String insertQuery = "{call insert_employee(?, ?)}"; try (CallableStatement cstmt = conn.prepareCall(insertQuery)) { cstmt.setString(1, "Queen"); cstmt.setDouble(2, 400000); cstmt.execute(); System.out.println("Sucessfully Inserted a record"); } } catch (SQLException se) { System.out.println("An error occured"); se.printStackTrace(); } } } //Procedure CREATE OR REPLACE PROCEDURE insert_employee( p_name IN VARCHAR2, p_salary IN NUMBER ) IS BEGIN -- Insert the employee with the given name and salary INSERT INTO employees (name, salary) VALUES (p_name, p_salary); -- Commit the transaction COMMIT; DBMS_OUTPUT.PUT_LINE('Employee inserted successfully!'); EXCEPTION WHEN OTHERS THEN -- Handle exceptions ROLLBACK; DBMS_OUTPUT.PUT_LINE('Error inserting employee: ' || SQLERRM); END; /