xiaodan_100081
xiaodan_100081
采纳率0%
2013-09-09 12:24 阅读 1.4k

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:@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)
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

1条回答 默认 最新

  • qq_34827482 qq_34827482 2016-11-09 05:48

    5个参数,只有4个问号call(?,?,?,?,?)

    点赞 评论 复制链接分享

相关推荐