jdbc callablestatement 2





package test;

import java.sql.*;

public class FiveJdbc {
    static final String url = "jdbc:oracle:thin:@192.168.3.211:1521:chi";
    static final String userID = "scott";
    static final String passwd = "oracle";
    Connection conn = null;
    ResultSet rs = null;
    CallableStatement  cstmt =null;
    
    public static void main(String[] args) {
        new FiveJdbc().TestCallable();
    }

    public void TestCallable(){
        try{
            Class.forName("oracle.jdbc.driver.OracleDriver");
            conn = DriverManager.getConnection(url, userID, passwd);
            cstmt = conn.prepareCall("{call test2_proc(?,?)}");
            cstmt.setInt(1, 12);
            cstmt.registerOutParameter(2, Types.VARCHAR);
            cstmt.execute();
            System.out.println("USERNAME = " + cstmt.getString(2));
            cstmt.close();
        }catch(Exception e){
            e.printStackTrace();
        }
        finally{
            if(conn!= null){
                try{conn.close();}catch(Exception ex){ex.printStackTrace();}
            }
        }
        
        }
        
    }
    

请使用浏览器的分享功能分享到微信等