当前位置:Gxlcms > mysql > mysql-java怎么调用MySQL存储过程?

mysql-java怎么调用MySQL存储过程?

时间:2021-07-01 10:21:17 帮助过:56人阅读

mysqljava存储过程

图片说明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));

人气教程排行