日期:2014-05-16 浏览次数:21126 次
CREATE or replace procedure test_emp(aename VARCHAR2,asal NUMBER) IS
BEGIN
UPDATE emp set sal=asal where ename=aename;
end;
package com.oracle.db;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.DriverManager;
public class OraclePro {
public static void main(String[] args) {
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection conn=DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:ORCL","scott","admin");
CallableStatement st=conn.prepareCall("{call test_emp(?,?)}");
st.setString(1, "SCOTT");
st.setInt(2,123);
System.out.println("执行");
st.execute();
System.out.println("OK");
st.close();
conn.close();
}catch (Exception e){
System.out.println("失败");
e.printStackTrace();
}
}
}