Java w/SQL Server Express 2008 - 索引超出范围异常

标签 java sql-server-2008 exception sql-server-express

我在 sql express 2008 中创建了一个存储过程,从 Java 方法调用该过程时出现以下错误:

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;
}

最佳答案

没有提供足够的源代码来确定,但根据堆栈跟踪,我的赌注是?占位符和提供的参数数量不匹配。我的猜测是你没有足够的占位符。我建议您仔细检查以确保每个数量都正确。

关于Java w/SQL Server Express 2008 - 索引超出范围异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2746488/

相关文章:

exception - MEF: "Unable to load one or more of the requested types. Retrieve the LoaderExceptions for more information"

java - 我的服务器结果集在循环时花费了很长时间

mysql - 删除不同数据库中没有相同代码的行

c# - 使用 Azure 移动服务从多个表读取数据

java - 在 GUI 中处理未处理的异常

java - jdbc连接socketexception错误

java - 安卓开发 : Run TimerTask in UI Thread

java - 删除 JTable 中的行后重新排序表数据

java - EJB 注入(inject)与仅 JSF 管理的 bean

SQL 查询以过滤特定记录计数的记录