注意: call的外面有大括号包围
执行前后需设置自动提交,执行时要false
Connection con = BaseDao.getConnection();
CallableStatement proc = null;
try {
conn.setAutoCommit(false);
proc = con.prepareCall("{call textabc(?,?)}");
proc.setInt(1, id);//输入
proc.setObject(2, "abc");//输出
proc.execute();
conn.setAutoCommit(true);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally {
try {
proc.close();
con.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}