[Java] JDBC 04 TestProc.java (对存储过程进行调用 CallableStatement)

call p(?, ?, ?, ?)}");     p 是 procedure 的名字 ,  视频讲解来自马士兵 : 11_JDBC处理存储过程, 我还不是很明白,因为没有实践过这个过程,以后看,SQL过程。
import java.sql.*;

public class TestProc {

    /**
     * @param args
     */
    public static void main(String[] args) throws Exception {

        Class.forName("oracle.jdbc.driver.OracleDriver");
        Connection conn = DriverManager.getConnection(
                "jdbc:oracle:thin:@192.168.0.1:1521:SXT", "scott", "tiger");
        CallableStatement cstmt = conn.prepareCall("{call p(?, ?, ?, ?)}");
        cstmt.registerOutParameter(3, Types.INTEGER);
        cstmt.registerOutParameter(4, Types.INTEGER);
        cstmt.setInt(1, 3);
        cstmt.setInt(2, 4);
        cstmt.setInt(4, 5);
        cstmt.execute();
        System.out.println(cstmt.getInt(3));
        System.out.println(cstmt.getInt(4));
        cstmt.close();
        conn.close();
    }

}

posted @ 2013-12-20 18:34  小尼人00  阅读(166)  评论(0编辑  收藏  举报