Java调用存储过程报错,存储过程有两个int型参数,在数据库里存储过程可以运行,运行结果如上图:java.sql.SQLException: Parameter index out of range (0 < 1 ).
代码如下,不知道怎么改?
public ArrayList getzhdltj(String Time,String Dzbm)
{
//定义一些变量
ResultSet rs=null;
Connection ct=null;
PreparedStatement csmt=null;
Statement ps=null;
ArrayList al = new ArrayList();
try
{
ct=(new ConnectDB()).ConnDB();
int Dzbmint=Integer.parseInt(Dzbm);
int Timeint=Integer.parseInt(Time);
//ct.setAutoCommit(false);
csmt=ct.prepareCall("{PRO_综合电力统计(IN_YEAR,IN_STATIONID)}");
csmt.setInt(0, Timeint);
csmt.setInt(1, Dzbmint);
csmt.execute();
ct.commit();
rs=csmt.executeQuery();
while(rs.next())
{
Wnbqgl nbqgl=new Wnbqgl();
//nbqgl.setMaxdl(rs.getDouble(2));
/*月计划发电量*/
nbqgl.setYjfdl(rs.getDouble(1));
nbqgl.setEjfdl(rs.getDouble(2));
nbqgl.setSjfdl(rs.getDouble(3));
nbqgl.setSijfdl(rs.getDouble(4));
nbqgl.setWjfdl(rs.getDouble(5));
nbqgl.setLjfdl(rs.getDouble(6));
nbqgl.setQjfdl(rs.getDouble(7));
nbqgl.setBjfdl(rs.getDouble(8));
nbqgl.setJjfdl(rs.getDouble(9));
nbqgl.setShijfdl(rs.getDouble(10));
nbqgl.setSyjfdl(rs.getDouble(11));
nbqgl.setSejfdl(rs.getDouble(12));
参考代码
conn = JdbcUtils.getConnection();
CallableStatement cstmt = (CallableStatement) conn.prepareCall("{call updatePopularUserMore(?,?,?,?,?)}", iRsType, iRsConcurrency);
cstmt.setObject("aUserId", aUserId);
cstmt.setObject("aMood", aMood);
cstmt.setObject("aPersonalityLabel", aPersonalityLabel);
cstmt.setObject("aFriendClaim", aFriendClaim);
cstmt.setObject("aHeaderPic", aHeaderPic);
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。