sql—用java编写存储函数(jdbc)

3qpi33ja  于 2021-06-26  发布在  Hive
关注(0)|答案(1)|浏览(542)

在尝试用java测试可调用过程时,我遇到了一个错误,当我尝试调用一个存储过程时,它报告了给定输入参数(int)的符号

CallableStatement cstmt = con.prepareCall("{CALL sign(?,"+testVal+")}");
    cstmt.registerOutParameter(1, Types.INTEGER);

堆栈跟踪显示:

java.sql.SQLException: [Cloudera][JDBC](11420) Error, parameter metadata not populated.
at com.cloudera.hiveserver2.exceptions.ExceptionConverter.toSQLException(Unknown Source)
at com.cloudera.hiveserver2.jdbc.common.SPreparedStatement.<init>(Unknown Source)
at com.cloudera.hiveserver2.jdbc.common.SCallableStatement.<init>(Unknown Source)
at com.cloudera.hiveserver2.jdbc.common4.C4SCallableStatement.<init>(Unknown Source)
at com.cloudera.hiveserver2.jdbc.jdbc41.S41CallableStatement.<init>(Unknown Source)
at com.cloudera.hiveserver2.jdbc.jdbc41.JDBC41ObjectFactory.createCallableStatement(Unknown Source)
at com.cloudera.hiveserver2.hive.jdbc41.HiveJDBC41ObjectFactory.createCallableStatement(Unknown Source)
at com.cloudera.hiveserver2.jdbc.common.SConnection.prepareCall(Unknown Source)
at TestMethods.callableStatement(TestMethods.java:263)
at HiveJdbcGeneralTest.testTableCreation(HiveJdbcGeneralTest.java:113)
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:497)
at
envsm3lx

envsm3lx1#

从错误消息中,我认为您正在尝试为配置单元编写存储过程。在本例中,您可以看到hpl/sql!=pl/sql语言。存储过程的正确语法可以在这里找到。

相关问题