时间:2021-07-01 10:21:17 帮助过:10人阅读
package junit.test;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.DriverManager;
/**
* 演示java程序调用oracle的存储过程案例
*
* @author jiqinlin
*
*/
public class ProcedureTest {
public static void main(String[] args) {
try {
// 1.加载驱动
Class.forName("oracle.jdbc.driver.OracleDriver");
// 2.得到连接
Connection ct = DriverManager.getConnection(
"jdbc:oracle:thin:@127.0.0.1:1521:orcl", "scott", "oracle");
// 3.创建CallableStatement
CallableStatement cs = ct.prepareCall("{call sp_update(?,?)}");
// 4.给?赋值
cs.setString(1, "SMITH");
cs.setInt(2, 4444);
// 5.执行
cs.execute();
// 关闭
cs.close();
ct.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
参见:http://www.cnblogs.com/linjiqin/archive/2012/02/23/2365429.html
oracle pl/sql 存储过程
标签:title 创建 san commit author static logs http www.