zoukankan      html  css  js  c++  java
  • 在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;
     }

  • 相关阅读:
    易语言常用源码
    ci的数据库地址
    格式化输出php数组
    mysql插入表情问题
    线程、进程与协程2
    线程、进程与协程
    if __name=='__main__"的作用
    动态导入模块
    面向对象补充之方法
    getpass模块
  • 原文地址:https://www.cnblogs.com/qixing/p/3047196.html
Copyright © 2011-2022 走看看