Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
724 views
in Technique[技术] by (71.8m points)

sql - Java: Calling a stored procedure in an oracle database

EDIT: 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 below IS the correct way to call a stored procedure of this type

I'm trying to call a simple stored procedure in an oracle database.

The procedure looks like this:

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 )
...

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();
    }

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.

Any help would be appreciated!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...