此后留白
2019-07-01 19:50
采纳率: 100%
浏览 701

java调用没有输出参数的存储过程获取返回结果集?

Java后台

sqlserver2008r2数据库

最后一个 ‘call1’那个存储过程。

public void getlist() throws Exception 
    {   
        Connection dao = JdbcConnection.getConn();


        String call = "{call Sc_ljycfwq(?, ?, ?, ?)}";
        CallableStatement callStatement = dao.prepareCall(call);
        callStatement.setString(1, "air");
        callStatement.setString(2, "XX.XX.XX.XXX");
        callStatement.setString(3, "sa");
        callStatement.setString(4, "XXXXXXXXX");
        callStatement.execute();
        callStatement.close();

        String call2 = "{call sp_serveroption(?, ?, ?)}";
        callStatement = dao.prepareCall(call2);
        callStatement.setString(1, "air");
        callStatement.setString(2, "rpc out");
        callStatement.setString(3, "true");
        callStatement.execute();
        callStatement.close();

        String call1 = "{call air.[XXX].dbo.sp_executesql(?, ?, ?, ?, ?, ?)}";
        callStatement = dao.prepareCall(call1);
        callStatement.setString(1, "exec rpt_MastCashRpt @P1,@P2,@P3,@P4");
        callStatement.setString(2, "@P1 varchar(20),@P2 varchar(20),@P3 varchar(4000),@P4 int");
        callStatement.setString(3, "2019-07-01");
        callStatement.setString(4, "2019-07-31");
        callStatement.setString(5, "(m.moneyid=0) and  1=1");
        callStatement.setInt(6, 0);
        callStatement.execute();
        callStatement.close();
        dao.close();

    }

1条回答 默认 最新

相关推荐 更多相似问题