jdbc - Callable Statement, cst 호출 저장 프로세스

3924 단어
package CST        ;



import java.sql.CallableStatement;

import java.sql.Types;



import org.junit.Test;



import     .dbUtils.Connection2;



/**

 * java      

 * 

 * @author lx

 * 

 */



public class CallableStatementDemo {

    /**

     *       

     * 

     * @throws Exception

     */

    @Test

    public void callPro2() throws Exception {

        //   CallableStatement  ,   PST  ,

        //       ?        

        String pro = "{call p1(?,?)}";

        //   CST  

        CallableStatement cst = Connection2.GetCon().prepareCall(pro);

        //       

        cst.setInt(1, 2);

        cst.setString(2, "  ");

        //   

        cst.executeUpdate();



    }

    

    /**

     *          

     * @throws Exception

     */

@Test

    public void call2() throws Exception {



        //          

        String sql = "{call p2(?,?,?)}";

        CallableStatement cst = Connection2.GetCon().prepareCall(sql);



        cst.setInt(1, 1);

        cst.setString(2, "JACK");

        //                    

        cst.registerOutParameter(3, Types.INTEGER);

        int a = cst.executeUpdate();

        System.err.println("    "+a);

        //     

        int count =cst.getInt(3);

        System.err.println("      "+count);

        Connection2.GetCon().close();



    }



}

좋은 웹페이지 즐겨찾기