2010-04-30 71 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