import java.sql.*; public class ProcTest { private static void testNoArgs(Connection conn) { try { CallableStatement stmt = conn.prepareCall("call non_existing_proc()"); stmt.executeUpdate(); } catch (Exception e) { System.err.println("No args: " + e.getClass().getSimpleName() + ": " + e.getMessage()); } } private static void testNumberedArg(Connection conn) { try { CallableStatement stmt = conn.prepareCall("call non_existing_proc_num_arg(?)"); stmt.setString(1, "foo"); stmt.executeUpdate(); } catch (Exception e) { System.err.println("Numbered arg: " + e.getClass().getSimpleName() + ": " + e.getMessage()); } } private static void testNumberedOutputArg(Connection conn) { try { CallableStatement stmt = conn.prepareCall("call non_existing_proc_num_outarg(?)"); stmt.registerOutParameter(1, Types.INTEGER); stmt.executeUpdate(); } catch (Exception e) { System.err.println("Numbered output arg: " + e.getClass().getSimpleName() + ": " + e.getMessage()); } } private static void testNamedArg(Connection conn) { try { CallableStatement stmt = conn.prepareCall("call non_existing_proc_named_arg(?)"); stmt.setString("argname", "foo"); stmt.executeUpdate(); } catch (Exception e) { System.err.println("Named arg: " + e.getClass().getSimpleName() + ": " + e.getMessage()); } } private static void testNamedOutputArg(Connection conn) { try { CallableStatement stmt = conn.prepareCall("call non_existing_proc_named_outarg(?)"); stmt.registerOutParameter("out_arg", Types.INTEGER); stmt.executeUpdate(); } catch (Exception e) { System.err.println("Named output arg: " + e.getClass().getSimpleName() + ": " + e.getMessage()); } } public static void main(String[] args) throws SQLException { if (args.length < 1) { System.err.println("Need jdbc uri as argument"); System.exit(1); } Connection conn = DriverManager.getConnection(args[0]); testNoArgs(conn); testNumberedArg(conn); testNumberedOutputArg(conn); testNamedArg(conn); testNamedOutputArg(conn); conn.close(); } }