日期:2014-05-18  浏览次数:20647 次

新手求助,JDBC处理存储过程出错
import java.sql.*;
public class TestProc {

public static void main(String[] args) throws Exception{
Class.forName("oracle.jdbc.driver.OracleDriver"); 
Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@192.168.1.101:1521:ORCL","scott","372158");
CallableStatement cstmt = conn.prepareCall("{call p(?, ?, ?, ?)}");
cstmt.registerOutParameter(3, Types.INTEGER);
cstmt.registerOutParameter(4, Types.INTEGER);
cstmt.setInt(1, 3);
cstmt.setInt(2, 4);
cstmt.setInt(4, 5);
cstmt.execute();
System.out.println(cstmt.getInt(3));
System.out.println(cstmt.getInt(4));
cstmt.close();
conn.close();
}
}

------解决方案--------------------
很清楚了啊,“参数个数和类型错误”,你看下存储过程的参数呢