日期:2014-05-16 浏览次数:20420 次
public static final String DBDRIVE = "oracle.jdbc.driver.OracleDriver"; public static final String DBURL = "jdbc:oracle:thin:@169.254.24.29:1521:orcl"; public static final String DBUSER = "scott"; public static final String DBPASSWORD= "tiger"; public static void main(String[] args) { Connection conn =null; CallableStatement cstmt = null; String sql = "{CALL myproc(?,?,?)}"; try { Class.forName(DBDRIVE); conn = DriverManager.getConnection(DBURL,DBUSER,DBPASSWORD); cstmt =conn.prepareCall(sql); cstmt.setInt(1,70); cstmt.setInt(2, 80); cstmt.registerOutParameter(2, Types.INTEGER); cstmt.registerOutParameter(3, Types.INTEGER); cstmt.execute(); cstmt.close(); conn.close(); } catch (SQLException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } }