2010-04-30 72 views
2

我创建一个SQL存储过程表示2008年和Java方法调用过程时,我发现了以下错误:Java的W/SQL Server Express的2008 - 索引超出范围异常

Index 36 is out of range. 
com.microsoft.sqlserver.jdbc.SQLServerException:Index 36 is out of range. 
    at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:170) 
    at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.setterGetParam(SQLServerPreparedStatement.java:698) 
    at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.setValue(SQLServerPreparedStatement.java:707) 
    at com.microsoft.sqlserver.jdbc.SQLServerCallableStatement.setString(SQLServerCallableStatement.java:1504) 
    at fr.alti.ccm.middleware.Reporting.initReporting(Reporting.java:227) 
    at fr.alti.ccm.middleware.Reporting.main(Reporting.java:396) 

我不知道它来自哪里...> _ <

任何帮助,将不胜感激。

问候, BS_C3


这里的一些源代码:

public ArrayList<ReportingTableMapping> initReporting(
     String division, 
     String shop, 
     String startDate, 
     String endDate) 
{ 
    ArrayList<ReportingTableMapping> rTable = new ArrayList<ReportingTableMapping>(); 

    ManagerDB db = new ManagerDB(); 
    CallableStatement callStmt = null; 
    ResultSet rs = null; 
    try { 
     callStmt = db.getConnexion().prepareCall("{call getInfoReporting(?,...,?)}"); 
     callStmt.setString("CODE_DIVISION", division); 
     . 
     . 
     . 
     callStmt.setString("cancelled", " "); 

     rs = callStmt.executeQuery(); 
     while (rs.next()) 
     { 
      ReportingTableMapping rtm = new ReportingTableMapping(
        rs.getString("werks"), ...); 

      rTable.add(rtm); 
     } 
     rs.close(); 
     callStmt.close(); 

    } catch (Exception e) { 
      System.out.println(e.getMessage()); 
      e.printStackTrace(); 
    } finally { 
      if (rs != null) 
       try { rs.close(); } catch (Exception e) { } 
      if (callStmt != null) 
       try { callStmt.close(); } catch (Exception e) { } 
      if (db.getConnexion() != null) 
       try { db.getConnexion().close(); } catch (Exception e) { } 
    } 

    return rTable; 
} 
+1

你正在做一个数组。需要java代码来获得任何帮助。 – 2010-04-30 17:40:49

回答

8

没有提供,以确保足够的源代码,但基于堆栈跟踪,我的赌注是数量?占位符和提供的参数数量不匹配。我的猜测是你没有足够的占位符。我建议仔细检查一下,确保每个人都有合适的人数。

0

非常感谢您的回答和时间。 我必须更改数据库中的库存程序,并在重写代码时错误消失。 我猜肖恩赖利是正确的=)

问候。 BS_C3