Select the correct option to be inserted at //INSERT CODE HERE that calls the database-stored procedure hello_world.
public class Main{ public static void main(String[] args) { try {/* ww w . j av a 2s . c o m*/ Connection con = getConnection(); //INSERT CODE HERE cs.setString(1, "test"); cs.registerOutParameter(2, Types.NUMERIC); cs.setInt(2, 10); System.out.println(cs.executeUpdate()); } catch (SQLException e) {} } }
a CallableStatement cs = con.prepareCall("{hello_world(?, ?)}"); b CallableStatement cs = con.prepareCall("{call procedure_hello_world(?, ?)}"); c CallableStatement cs = con.prepareCall("{call hello_world}"); d CallableStatement cs = con.prepareCall("{call hello_world(?, ?)}"); e CallableStatement cs = con.prepareCall("hello_world(?, ?)");
d
To call a stored procedure using Java's CallableStatement, you must prefix the procedure name with the word call.
Stored procedures that accept method parameters must be followed by parentheses.
The question marks used in the code in this question are place holders to insert variable values.