jdbc处理存储过程的小程序出错啦 向各位大神请教一下
2014-04-19 来自:天玄青鸟 0 人回应

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:@127.0.0.1:1521:orcl", "scott", "1234");
    CallableStatement cal = conn.prepareCall("{call p(?,?,?,?)}");
    cal.registerOutParameter(3, Types.INTEGER);
    cal.registerOutParameter(4, Types.INTEGER);
    cal.setInt(1, 3);
    cal.setInt(2, 4);
    cal.setInt(4, 1);
    cal.execute();
    System.out.println(cal.getInt(3));
    System.out.println(cal.getInt(4));
    cal.close();
    conn.close();
}

}

出错信息:
Exception in thread "main" java.sql.SQLException: ORA-06550: 第 1 行, 第 7 列:
PLS-00306: 调用 'P' 时参数个数或类型错误
ORA-06550: 第 1 行, 第 7 列:
PL/SQL: Statement ignored

at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:189)
at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:242)
at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:554)
at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1478)
at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:888)
at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:2076)
at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:1986)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2697)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:457)
at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:531)
at Testproc2.main(Testproc2.java:16)
还没有人回应!

您的回应

你还未登陆,不能回应!登陆