java调用oracle存储过程

String driver = "oracle.jdbc.driver.OracleDriver";
    String strUrl = "jdbc:oracle:thin:@localhost:orabi";
    Statement stmt = null;
    ResultSet rs = null;
    Connection conn = null;
    CallableStatement proc = null;
   
    try {
Class.forName(driver);
conn = DriverManager.getConnection(strUrl, "prd_stg_tz", "dev_stg_tz");
proc = conn.prepareCall("{call sp_consign_id(?,?,?,?)}");
proc.setInt(1, 1);
proc.setString(2, "BUS_WATERWAY_FREIGHT");
proc.setInt(3, 1);
proc.registerOutParameter(4, Types.VARCHAR);
proc.execute();
System.out.println(proc.getString(4));
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}

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