【发布时间】:2018-05-31 14:33:00
【问题描述】:
在尝试在 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
【问题讨论】:
-
一个错误是total(origin STRING)后面的分号
-
已修复!同样的错误仍然;但是。
-
阅读错误消息和参考我认为有一些像
CREATE FUNCTION [db_name.]function_name AS class_name [USING JAR|FILE|ARCHIVE 'file_uri' [, JAR|FILE|ARCHIVE 'file_uri'] ]; -
鉴于这是一个执行相当简单功能的(数据库)存储过程,我想我对为什么需要这样做有点困惑。
-
除非return指的是变量名,而as指的是变量的返回类型
标签: java sql hive callable-statement