mysql 存储过程(一)

存放位置:

database:mysql

table:proc

后台显示(下面3种方法都可以):

show procedure status;

select name,db from mysql.proc;

show create procedure;

调用方法

1.       后台直接调用

Call procedureName

 

2.       java 调用

    public void testProcedure() throws DataManagerException {

 

        Connection conn = super.getCon();

        ResultSet rs = null;

        CallableStatement cs = null;

        String a = null;

        try {

           // procedure is test()

            CallableStatement cStmt = conn.prepareCall("{call test()}");

            rs = cStmt.executeQuery();

            while (rs.next()) {

                String value = rs.getString(2);

                System.out.println(value);

             }

        } catch (Exception e) {

            System.out.println("hahad" + e.getMessage());

        } finally {

            try {

                conn.close();

            } catch (Exception ex) {

                System.out.println("ex : " + ex.getMessage());

            }

        }

    }

转载于:https://www.cnblogs.com/cathyera/archive/2008/07/30/1256666.html

你可能感兴趣的:(mysql 存储过程(一))