• 在S2SH中调用返回参数的存储过程


    在SqlServer中创建存储过程:

    create proc test
    @result int output  ---输出参数
    as
    begin
    declare @test varchar(50)
    declare @count int
    select @test='this is test proc result:'
    select @count = count(*) from GOODSCODE
    set @result=@count
    print @test
    print @count
    end

    其实,Hibernate中还没发现,其集成处理存储过程的方法,但是可通过Session获得对数据库的连接,走Java调用存储过程的路线

    service代码如下:

     public List sqlQuery() {
      Connection connection = null;
      CallableStatement statement = null;
      ResultSet rs = null;
      connection=factory.getCurrentSession().connection();
      try {
       statement = connection.prepareCall("{Call test(?)}");
       statement.registerOutParameter(1, java.sql.Types.INTEGER);
       statement.execute();
       System.out.println(statement.getInt(1));
      } catch (SQLException e) {
       e.printStackTrace();
      }


      
      
      return null;
     }

  • 相关阅读:
    占位博客
    占位博客
    占位博客
    占位
    占位
    占位
    占位
    占位
    python字典设置初始值setdefault()与get()
    自然语言处理如何入门
  • 原文地址:https://www.cnblogs.com/qixing/p/3047196.html
Copyright © 2020-2023  润新知