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.
Free AppAndroid App

Coursify Android App

Generate AI courses, take quick quizzes between classes, and master complex engineering concepts on the go.

← All Introduction to Java Programming modules