Jdbc 弹簧贮存工艺
我们可以通过索引而不是名称将输出和输入参数传递给SQLParameter吗Jdbc 弹簧贮存工艺,jdbc,Jdbc,我们可以通过索引而不是名称将输出和输入参数传递给SQLParameter吗 /* This code snippet explains data access thru CallableStatement by registering the output and input params by index. */ Connection conn = getConnection(); CallableStatement sp = conn.prepareCall("p
/* This code snippet explains data access thru CallableStatement by registering the output and input params by index. */
Connection conn = getConnection();
CallableStatement sp = conn.prepareCall("pkg_name.proc_name");
sp.registerOutParameter(1, oracle.jdbc.driver.OracleTypes.CURSOR);
sp.registerOutParameter(2, oracle.jdbc.driver.OracleTypes.NUMBER);
ResultSet rs = (ResultSet) sp.getObject(2);
这里可以根据索引获取resultset
请建议。是的,我们可以。他是你的朋友
public void registerOutParameter(String parameterName,
int sqlType)
throws SQLException;
对不起,我错过了一些东西。对不起,我错过了一些东西。我正在尝试使用SpringAPI-StoredProcess。在使用这个时,我们必须按类型名传入输出和输入参数。是否有一种方法可以传递paramIndex而不是通过名称进行强绑定。私有类MyStoredProcedure扩展StoredProcedure{private static final String SQL=“sysdate”;公共MyStoredProcedure(DataSource ds){setDataSource(ds);setFunction(true);setSql(SQL);declareParameter(新的SqlOutParameter(“date”,Types.date));compile();}public Map execute(){//“sysdate”存储过程没有输入参数,因此提供了一个空映射…return execute(新的HashMap());}