在java中执行存储过程方法如下(以下例子是我在做dorado项目中所用的方法)
import java.sql.Connection;
import java.sql.PreparedStatement;
*********执行的方法里面写如下代码
Transaction trans = TransactionManager.getTransaction();
trans.beginTransaction();
Connection con = trans.getConnection(Setting.getString("common.defaultDataSource"));//此处根据不同的数据连接可以改写
PreparedStatement pstmt = con.prepareStatement("{call P_RPT_XXXX(? , ? , ? , ?)}");//调用存储过程名
pstmt.setString(1, code);//传参
pstmt.setString(2, bMonth);
pstmt.setString(3, eMonth);
pstmt.setString(4, id);
pstmt.execute();
****最后关闭
trans.commit();
pstmt.close();
con.close();