先生,
作为后端开发人员,我想调用连接Oracle 9i
数据库的存储过程以获取单个输出String。
实际上,输出参数的结果为String,返回空。
[请您告诉我对作品进行哪些修改?
这里是我的休息管理员:
@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;
@ raju,使用带有Springboot注释的Jpa模板可能会对您有所帮助。
Controller class
{
@Autowired
B b;
@GetMapping(value = { "/third"})
public String getVariable (){
return b.getInfo();
}
}
@service
B
{
@Autowired
A a;
public String getInfo()
{
return a.getoutput();
}
@repository
interface A extends JpaRepository<Mention your Entity,String>()
{
@procedure(name="Execute your_procedure name")
//return type
public String getoutput();
}
}