0

I am calling procedure from java code:

private String processData(Integer time, String jndiName) {
    CallableStatement cs = null;
    Connection conn = null;
    try {
        InitialContext ctxt = new InitialContext();
        DataSource ds = (DataSource) ctxt.lookup(jndiName);
        conn = ds.getConnection();
        cs = conn.prepareCall("{call PROC(?)}");
        cs.setInt(1, time);
        cs.execute();
    } catch (Exception e) {

    }

This procedure just waiting for X second which I set as parameter.

The question is:

How long will take this java function when I call this procedure with parameter time=30?
It will wait untill this procedure ends or java will just run it and continue to next command ?

1
  • btw, slightly unrelated, but you should close the connection in a finally block (otherwise you would run in to connection leaks).
    – Vikdor
    Aug 16, 2012 at 10:50

2 Answers 2

1

Yes, it will wait, it's a blocking operation.

3
  • hm is there some options how I can run this in another thread and continue in application ?
    – hudi
    Aug 16, 2012 at 10:46
  • Create a class that implements Runnable and wrap the processData method inside run. Then, you can just call it like this new Thread(new YourRunnable()).start(). Aug 16, 2012 at 10:49
  • @hudi this may be of interest
    – T I
    Aug 16, 2012 at 10:49
1

CS.execute is a blocking call, waits for the database to complete the procedure call and then only returns.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.