Java:在oracle数据库中调用存储过程 [英] Java: Calling a stored procedure in an oracle database
问题描述
虽然此问题的某些答案可能会帮助其他遇到不同问题的人,但该解决方案实际上与数据库连接上的自动提交功能中的某些错误有关!执行查询后强制执行提交会使数据库反映更改,因此下面显示的代码是调用此类型存储过程的正确方法
我正在尝试在oracle数据库中调用一个简单的存储过程.
I'm trying to call a simple stored procedure in an oracle database.
过程如下:
procedure clear_orderProcDtlByOrdId(p_order_id in order_header.order_id%type,
p_transaction_id in sl_order_processing_dtl.transaction_id%type DEFAULT NULL,
p_item_action_id in sl_order_processing_dtl.item_action_id%type DEFAULT NULL )
...
我遇到麻烦的Java代码如下
The java code I'm having trouble with looks like this
try
{
CallableStatement storedProc = conn.prepareCall("{call PKG_PI_FRAUD.clear_orderProcDtlByOrdId(?)}");
storedProc.setString(1, orderID);
storedProc.execute();
}
catch (SQLException e)
{
e.printStackTrace();
}
我根本没有收到任何错误,但是没有反映出数据库更改.当我在SQL Developer中运行该过程时,我看到了结果.我以为可能是因为提交问题,但是我建立的连接处于自动提交模式.
I'm not receiving any errors at all, however there are no database changes being reflected. When I run the procedure in SQL Developer I see results. I thought it might be because of a commit issue, but the connection I have established is in auto-commit mode.
任何帮助将不胜感激!
推荐答案
此问题中的某些答案可能会帮助其他遇到不同问题的人,但该解决方案实际上与数据库连接上的自动提交功能相关的一些错误有关!执行查询后强制执行提交会使数据库反映更改,因此问题中显示的代码是调用此类型存储过程的正确方法!
While some of the answers in this question may help others with different problems, the solution was actually related to some bug with the auto-commit feature on a database connection! Forcing a commit after executing the query caused the database to reflect the changes, thus the code shown in the question IS the correct way to call a stored procedure of this type!
这篇关于Java:在oracle数据库中调用存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!