标签:
只需注意一点输出参数是用CallableStatement里面的registerOutParameter方法注册进去
存储过程:
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Types;
//在java中调用oracle的存储过程
public class JavaCallpro {
public static void main(String[] args) {
String driver="oracle.jdbc.driver.OracleDriver";
String url="jdbc:oracle:thin:@127.0.0.1:1521:orcl";
String user="scott";
String password="ztoracle";
try {
Class.forName(driver);
Connection c=DriverManager.getConnection(url, user, password);
CallableStatement cs=c.prepareCall("{call my_pro(?,?,?)}");
cs.setString(1, "9527");
cs.registerOutParameter(2, Types.VARCHAR);
cs.registerOutParameter(3, Types.VARCHAR);
cs.execute();
System.out.println(cs.getString(2));
} catch (ClassNotFoundException e) {
throw new RuntimeException();
} catch (SQLException e) {
}
}
}
oracle pl/sql之在java中调用带有输入输出参数的oracle存储过程
标签:
原文地址:http://www.cnblogs.com/ztyy04126/p/4901548.html