日期:2014-05-16  浏览次数:20521 次

Java类TestStoreProcedure.java测试存储过程
使用下面的Java类TestStoreProcedure.java测试存储过程。

package test;

import java.sql.CallableStatement;

import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.SQLException;

import oracle.jdbc.OracleTypes;

    /**

     * This class is used to test Oracle store procedure

     * @author CarlWu

     *

     */

    public class TestStoreProcedure{



              /**

               * 测试主方法

               * @param args

               */

              public static void main(String[] args) {

                       Connection con=null;

                       try {

                                //获得数据库连接

                                java.lang.Class.forName("oracle.jdbc.driver.OracleDriver");

                                con = DriverManager.getConnection("jdbc:oracle:thin:scott/tiger@localhost:1521:LEGDB");

                                //测试存储过程

                                TestStoreProcedure sp=new TestStoreProcedure();

                                sp.execute(con,"carl_sp_test","carl");

                       } catch (ClassNotFoundException cnfe) {

                                cnfe.printStackTrace();

                       } catch (SQLException sqlE) {

                                sqlE.printStackTrace();

                       }catch(Exception e){