PL/SQL: Statement ignored 异常 关于存储过程的调用

Posted aniymx

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PL/SQL: Statement ignored 异常 关于存储过程的调用相关的知识,希望对你有一定的参考价值。

C:Javajdk8injava -ea -Didea.test.cyclic.buffer.size=1048576 "-javaagent:D:InstalledIntelliJ IDEA 2017.3.4libidea_rt.jar=3706:D:InstalledIntelliJ IDEA 2017.3.4in" -Dfile.encoding=UTF-8 -classpath "D:InstalledIntelliJ IDEA 2017.3.4libidea_rt.jar;D:InstalledIntelliJ IDEA 2017.3.4pluginsjunitlibjunit-rt.jar;D:InstalledIntelliJ IDEA 2017.3.4pluginsjunitlibjunit5-rt.jar;C:Javajdk8jrelibcharsets.jar;C:Javajdk8jrelibdeploy.jar;C:Javajdk8jrelibextaccess-bridge-64.jar;C:Javajdk8jrelibextcldrdata.jar;C:Javajdk8jrelibextdnsns.jar;C:Javajdk8jrelibextjaccess.jar;C:Javajdk8jrelibextjfxrt.jar;C:Javajdk8jrelibextlocaledata.jar;C:Javajdk8jrelibext
ashorn.jar;C:Javajdk8jrelibextsunec.jar;C:Javajdk8jrelibextsunjce_provider.jar;C:Javajdk8jrelibextsunmscapi.jar;C:Javajdk8jrelibextsunpkcs11.jar;C:Javajdk8jrelibextzipfs.jar;C:Javajdk8jrelibjavaws.jar;C:Javajdk8jrelibjce.jar;C:Javajdk8jrelibjfr.jar;C:Javajdk8jrelibjfxswt.jar;C:Javajdk8jrelibjsse.jar;C:Javajdk8jrelibmanagement-agent.jar;C:Javajdk8jrelibplugin.jar;C:Javajdk8jrelib
esources.jar;C:Javajdk8jrelib
t.jar;D:ideaworkspaceday02_oracle_jdbc	arget	est-classes;E:mavenSSMRepository
epositorycomoracleojdbc1410.2.0.4.0ojdbc14-10.2.0.4.0.jar;E:mavenSSMRepository
epositoryjunitjunit4.12junit-4.12.jar;E:mavenSSMRepository
epositoryorghamcresthamcrest-core1.3hamcrest-core-1.3.jar" com.intellij.rt.execution.junit.JUnitStarter -ideVersion5 -junit4 com.itheima.test.TestJdbc,test02

java.sql.SQLException: ORA-06550: 第 1 行, 第 7 列: 
PLS-00201: 必须声明标识符 ‘PROC_COUNTYEARSAL‘
ORA-06550: 第 1 行, 第 7 列: 
PL/SQL: Statement ignored


    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
    at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
    at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
    at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:743)
    at oracle.jdbc.driver.T4CCallableStatement.doOall8(T4CCallableStatement.java:212)
    at oracle.jdbc.driver.T4CCallableStatement.executeForRows(T4CCallableStatement.java:951)
    at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1160)
    at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3285)
    at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3390)
    at oracle.jdbc.driver.OracleCallableStatement.execute(OracleCallableStatement.java:4223)
    at com.itheima.test.TestJdbc.test02(TestJdbc.java:47)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
    at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)


Process finished with exit code -1

异常的原因是因为在进行存储过程调用的中,数据库中没有该存储过程,

下面是我写的代码,因为在其他用户下面创建了一个存储过程,该用户下面并没有,而在进行数据库连接的时候连接了scott用户造成的,算是粗心造成的吧

 @Test
    public void test02() throws Exception {
        String driver = "oracle.jdbc.OracleDriver";
        String url = "jdbc:oracle:thin:@192.168.80.88:1521:orcl";
        String username = "scott";
        String password = "tiger";
        Class.forName(driver);

        Connection connection = DriverManager.getConnection(url, username, password);

        CallableStatement pstm = connection.prepareCall("{call proc_countyearsal(?, ?)}");
        //给参数赋值
        pstm.setObject(1, 7788);
        pstm.registerOutParameter(2, OracleTypes.VARCHAR);
        //执行数据库查询操作
        pstm.execute();
        //输出结果[第二个参数]
        System.out.println(pstm.getObject(2));
        //释放资源
        pstm.close();
        connection.close();
}

 

以上是关于PL/SQL: Statement ignored 异常 关于存储过程的调用的主要内容,如果未能解决你的问题,请参考以下文章

PL/SQL loop循环详解

PL/SQL轻量版——游标与异常处理

pl/sql:在oracle中选择作为函数的参数/参数

将oracle.sql.ARRAY传递给PL / SQL过程时设置时区

一个存储过程,报错如下 13 PL/SQL:ORA-00922:缺少或无效选项 13 PL/SQL:SQL Statement ignored

JDBC Statements, PreparedStatement和CallableStatement语句