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

  • 相关阅读:
    Linux下修改/设置环境变量JAVA_HOME
    php WNMP(Windows+Nginx+Mysql+php)配置笔记
    jetty
    eclipse 打包
    js 稍微判断下浏览器 pc 还是手机
    mysql 自增长
    mac 终端命令
    KVC,KVO
    Swift
    构造函数,析构函数的区别
  • 原文地址:https://www.cnblogs.com/qixing/p/3047196.html
Copyright © 2011-2022 走看看