Introduction to Java Database Connectivity · Introduction to Java Programming

Callable Statement

Watch lectures

Callable Statement

1. What Is CallableStatement? (beginner)

CallableStatement = JDBC caller for stored procedures ({call name(?,?)}). Handles IN (give!), OUT (take!), INOUT (both!). Extends PreparedStatement (safe params!).

2. Code — IN + OUT (exam pattern!)

-- DB: bonus adds 10% and returns total!
CREATE PROCEDURE bonus(IN id INT, OUT total INT)
BEGIN SELECT salary * 1.1 INTO total FROM emp WHERE eid = id; END

3. Param Kinds (exam table!)

Kind Java Example
IN setInt(1, x) input only!
OUT registerOut + getInt output only!
INOUT set + register + get both!

4. Traps

  • Index from 1 (not 0!). {call ...} braces REQUIRED!
  • registerOutParameter BEFORE execute (else ERROR!).
  • executeQuery (rows!) vs executeUpdate (count!) vs execute (either/procedure!).

5. Exam Points

  • IN+OUT program — 7 marks, very frequent.
  • Register + index-1 + braces — 3-5 marks, favourite traps.
AI LearningWeb Platform

Coursify — Personal AI Course Generator

Struggling with a difficult subject or concept? Turn any engineering topic into a structured course with interactive lessons, quizzes, and research-backed explanations.

← All Introduction to Java Programming modules