先创建一个存储过程内容为:
    select * from student Java代码:
       Connection cn = //连接数据库;
       Statement stmt = cn.createStatement();
       ResultSet rs = stmt.executeQuery("exec 存储过程名");
  就ok了.

解决方案 »

  1.   

    CREATE PROCEDURE dbo.p_selectStudent
    AS
        BEGIN
           select * from student
           return 0
      END
      

  2.   

    1.java.sql.Connection conn
    2.java.sql.CallableStatement cs 
      cs = conn.prepareCall("{call 存储过程名(参数1,参数2...,参数n)}");
    3.在cs上设置参数值,还可以设置返回参数:如
      cs.setInt(1,123); //一般参数
      cs.registerOutParameter(序号,参数类型)//返回参数
    4.cs.execute()执行
    5.最后关闭:
      cs.close();
      conn.close();
      

  3.   

    String strSql="{?=call p_selectStudent}";
    CallableStatement call = null;
    call=conn.prepareCall(strSql);
    call.registerOutParameter(1,Types.INTEGER);
    call.execute();
    ResultSet rs=call.getResultSet();