2011-10-07 63 views
0

我已经编写了应该从我的servlet调用MSSQL 2005过程的代码。问题是程序是从表中选择数据,所以我想要得到的ResultSet,但结果集永远不会返回:(我测试过程与另一个程序,它的工作原理,此外,客户端连接权限是dbowner所以应该没有问题连接,但仍执行返回false :(MS SQL JDBC - SQLServerCallableStatement - execute()返回false

这里的问题是代码(当前连接连接我选中):

... 
    SQLServerCallableStatement callableStatement = null; 
    callableStatement = (SQLServerCallableStatement) connection.prepareCall(
         "{call "+ 
         DATABASE_NAME+ 
         "."+ 
         SCHEMA_NAME+ 
         ".select_item_proc(?,?,?)}"); 

         callableStatement.setInt(1, 0); 
       callableStatement.setString(2, "value1"); 
       callableStatement.setString(3, "value2"); 

      boolean rs=callableStatement.execute(); 

      if(rs) 
      { 
      ResultSet result=callableStatement.getResultSet(); 




       while (result.next()) { 

        String col1= result.getString(1); 
        String col2=result.getString(2); 
        System.out.print(col1+","); 
        System.out.println(col2); 


       } 


} 
... 

所以我需要你的新鲜景象是什么问题真的可以任意?赞赏有用的评论

回答

2

请尝试使用ResultSet rs = callableStatement.executeQuery();而不是boolean rs=callableStatement.execute();一行。

+0

谢谢...其实问题也是在params值,但executeQuery()帮助我 – user592704