单位用的jsp,但是我不知道jsp怎么调用存储过程能给出例子代码最好啦~还有就是调用的是存储过程名称呢?还是调用存储过程里面定义的变量呢?

解决方案 »

  1.   

    exec 存储过程名称 '变量1','变量2'
      

  2.   

    SQLCOMMAND类,有COMMANDTYPE,是选择存储过程的,去JSP问下,
      

  3.   

    要在jdbc中直型数据库中的存储过程,可以使用CallableStatement对象,其由Connection的prepareCall方法创建,其参数为字符串,该字符串是调用存储过程的语句,格式为:"{call   procedureName 执行存储过程则用方法:executeQuery()或者execute().
      

  4.   

    一段代码 参考一下:
    public void setRecord()
     {    
      Connection con = ConnectionFactory.getConn();
      CallableStatement cst = null;
      ResultSet rs =null;
      String query = "{call getrecords(?)}";
      try {
       cst = con.prepareCall(query);
       cst.registerOutParameter(1,Types.INTEGER);
       cst.execute();
       recordCount=cst.getInt(1);
       System.out.println("记录总数:"+recordCount);
      } catch (SQLException e) {
       // TODO 自动生成 catch 块
       e.printStackTrace();
      }
      ConnectionFactory.close(cst);
      ConnectionFactory.close(con);
     } 
      

  5.   

    exec偶知道,因为我写了一个存储过程
    就设置了一个变量,然后我突然想到jsp要是调用的话,要是调用变量我就麻烦了
    存储过程代码如下use test3
    if exists(select name from sysobjects where name ='s_map_address' and type='p')
    drop procedure s_map_address
    go
    create procedure s_map_address
    @inprint varchar(800)
    asSELECT economies.name, land.name AS l_name, 
          economies.address
    FROM economies INNER JOIN
          land ON economies.land_id = land.id
    where economies.name like '%'+@inprint or land.name like '%'+@inprint+'%' or
          economies.address like '%'+@inprint+'%'
    像这样的,是写多变量好呢?还是一个变量好呢?