【发布时间】:2019-11-19 10:12:11
【问题描述】:
作为后端开发人员,我想调用连接Oracle 9i 数据库的存储过程来获取单个输出字符串。
实际上,输出参数的结果为字符串,返回空。
您能告诉我要对作品进行哪些修改吗?
这是我的休息控制器:
@GetMapping(value = { "/third"})
public String getVariable (){
String result = "" ;
Connection conn;
conn = getConnection() ;
CallableStatement cstmt = null;
try {
String SQL = "{call pkg1234.get_pc_lookup_value_second(?,?)}";
cstmt = conn.prepareCall (SQL);
cstmt.setString(1, "TES");
cstmt.registerOutParameter(2, oracle.jdbc.OracleTypes.VARCHAR );
cstmt.execute();
String dddresult = cstmt.getString(2);
System.out.println(" Record :"+dddresult);
result = dddresult;
}
catch (SQLException e) {
System.out.println(" go this");
e.printStackTrace();
}
return result ;
}
这是我的存储过程:
PROCEDURE get_pc_lookup_value_second (
i_lookup_code IN VARCHAR2,
o_lookup_value OUT VARCHAR2
)
o_lookup_value := '456';
END get_pc_lookup_value_second;
【问题讨论】:
-
你为什么在 Spring 中使用普通的 jdbc?在 spring 中有类似 jdbc 模板的方法可以轻松处理这类事情。
-
什么样的模板?我使用模板和 jpa 但无济于事。没有人回答我之前的问题,所以我使用原始方法
-
这个问题的大部分材料都莫名其妙地编辑成答案(!),这反过来又需要大量编辑,以区分问题作者和答案作者的声音。我断言答案中的材料意味着这个问题缺少minimal reproducible example,因此可以作为题外话关闭。
-
请不要在未来以这种方式添加细节 - 这会导致令人绝望的问答,并且在 Stack Overflow 的目标方面会适得其反。我们正在努力整理对未来广大读者有用的材料。
标签: java spring oracle jdbc oracle9i