CallableStatement cs = null;
try{
cs = con.prepareCall("{ ? = call sp_test(?,?,?) }");
int idx = 0;
cs.registerOutParameter(++idx, Types.INTEGER);
cs.setString(++idx, COL_1);
cs.setString(++idx, COL_2);
cs.setString(++idx, COL_3);
cs.execute();
int result = cs.getInt(1);
if(result == -1){ //check error
throw new SQLException("result is -1"); //=-=> 좀 더 정형화된 다른 예외를 만들어야...
}
return result;
}catch(Exception e){
throw new RuntimeSQLException(e, primaryKey);
}finally{
if(cs != null){ try{ cs.close(); }catch(Exception ignored){ } }
}
Recent comment