JAVA 调用存储过程报错 java.sql.SQLException: 无效的列索引
报错信息java.sql.SQLException:无效的列索引atoracle.jdbc.driver.OracleCallableStatement.register...
报错信息
java.sql.SQLException: 无效的列索引
at oracle.jdbc.driver.OracleCallableStatement.registerOutParameterInternal(OracleCallableStatement.java:125)
我的代码报错在这里
at com.sino.base.db.procedure.SQLStoreProcedure.execProcedure(SQLStoreProcedure.java:72)
at com.sino.ies.basedefine.project.plan.dao.ProjectPlanDao.searchdetailplanQTYData(ProjectPlanDao.java:839)
以下为我的方法的代码
public void searchdetailplanQTYData(HttpServletRequest req, String[] detailParam) throws Exception {
// TODO Auto-generated method stub
String sqlProcedure = "BEGIN IES_ITEM_PLAN_AVABLE_QTY.AVAILABLE_PLAN_CURSOR_NEW(?,?,?,?) ; END;";
try {
SQLProcedureParameterList paraList = new SQLProcedureParameterList();
paraList.setParameter(SQLProcedureParameter.STRING, "P_PRODUCT_ID",
detailParam[0], SQLProcedureParameter.IN);
paraList.setParameter(SQLProcedureParameter.INTEGER,
"P_PROJECT_ID", detailParam[1],
SQLProcedureParameter.IN);
paraList.setParameter(SQLProcedureParameter.INTEGER, "P_ORGAN_ID",
detailParam[2],
SQLProcedureParameter.IN);
paraList.setParameter(SQLProcedureParameter.STRING,
"P_BEGIN_DATE", detailParam[3], SQLProcedureParameter.IN);
paraList.setParameter(SQLProcedureParameter.OBJECT, "P_IMP_MSG_INFO",
null, SQLProcedureParameter.OUT);
paraList.setParameter(SQLProcedureParameter.INTEGER, "P_MSG_CODE",
null, SQLProcedureParameter.OUT);
paraList.setParameter(SQLProcedureParameter.STRING, "P_MSG_INFO",
null, SQLProcedureParameter.OUT);
SQLStoreProcedure proc = new SQLStoreProcedure();
proc.setConnection(conn);
proc.execProcedure(sqlProcedure, paraList, null);
RowSet rowSet = proc.getCursorRowSet("P_IMP_MSG_INFO");
req.setAttribute(QueryConstant.SPLIT_DATA_VIEW, rowSet);
} finally {
}
}
已经找到原因了,因为占位符写少了,我只写了进的参数的占位符,没写出的占位符,所以报错,第一次写这个,实在蛋疼,谢谢大家了。 展开
java.sql.SQLException: 无效的列索引
at oracle.jdbc.driver.OracleCallableStatement.registerOutParameterInternal(OracleCallableStatement.java:125)
我的代码报错在这里
at com.sino.base.db.procedure.SQLStoreProcedure.execProcedure(SQLStoreProcedure.java:72)
at com.sino.ies.basedefine.project.plan.dao.ProjectPlanDao.searchdetailplanQTYData(ProjectPlanDao.java:839)
以下为我的方法的代码
public void searchdetailplanQTYData(HttpServletRequest req, String[] detailParam) throws Exception {
// TODO Auto-generated method stub
String sqlProcedure = "BEGIN IES_ITEM_PLAN_AVABLE_QTY.AVAILABLE_PLAN_CURSOR_NEW(?,?,?,?) ; END;";
try {
SQLProcedureParameterList paraList = new SQLProcedureParameterList();
paraList.setParameter(SQLProcedureParameter.STRING, "P_PRODUCT_ID",
detailParam[0], SQLProcedureParameter.IN);
paraList.setParameter(SQLProcedureParameter.INTEGER,
"P_PROJECT_ID", detailParam[1],
SQLProcedureParameter.IN);
paraList.setParameter(SQLProcedureParameter.INTEGER, "P_ORGAN_ID",
detailParam[2],
SQLProcedureParameter.IN);
paraList.setParameter(SQLProcedureParameter.STRING,
"P_BEGIN_DATE", detailParam[3], SQLProcedureParameter.IN);
paraList.setParameter(SQLProcedureParameter.OBJECT, "P_IMP_MSG_INFO",
null, SQLProcedureParameter.OUT);
paraList.setParameter(SQLProcedureParameter.INTEGER, "P_MSG_CODE",
null, SQLProcedureParameter.OUT);
paraList.setParameter(SQLProcedureParameter.STRING, "P_MSG_INFO",
null, SQLProcedureParameter.OUT);
SQLStoreProcedure proc = new SQLStoreProcedure();
proc.setConnection(conn);
proc.execProcedure(sqlProcedure, paraList, null);
RowSet rowSet = proc.getCursorRowSet("P_IMP_MSG_INFO");
req.setAttribute(QueryConstant.SPLIT_DATA_VIEW, rowSet);
} finally {
}
}
已经找到原因了,因为占位符写少了,我只写了进的参数的占位符,没写出的占位符,所以报错,第一次写这个,实在蛋疼,谢谢大家了。 展开
1个回答
2016-05-25
展开全部
游标参数在哪一位登记的就在哪一位取,
call.registerOutParameter(4, oracle.jdbc.OracleTypes.CURSOR); //在第4个登记
ResultSet rs = (ResultSet) call.getObject(4); //在第4个取
call.registerOutParameter(4, oracle.jdbc.OracleTypes.CURSOR); //在第4个登记
ResultSet rs = (ResultSet) call.getObject(4); //在第4个取
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询