Java block when execute Oracle Procedure

378 Views Asked by At

I have a problem can not solve ,i use ojdbc7 libraries to connect java to a database Oracle11g but at launch of the procedure when this ends the java application does not go forward without responce. I tried to change driver ojdbc but nothing you know give me some ideas ? I am attaching the code :

private static HashMap<String, Connection> connessioni = new HashMap<>();

....
public static Connection getConnectionIstance(String connessione){
        Connection connection=null;
        try{
            if((connection=connessioni.get(connessione))==null){                    
                     Class.forName("driver");    
                     connection=DriverManager.getConnection("urlDb","userDb","pwdDb");
                     connection.setAutoCommit(false);
                     connessioni.put(connessione, connection);

            }
        }catch(SQLException e){
            e.printStackTrace();
        }catch(ClassNotFoundException e){
            e.printStackTrace();
        }catch(Exception e){
            e.printStackTrace();
        }

        return connection;
    }

main

....

CallableStatement callStatement=null;
callStatement = connection.prepareCall({call nomePkg.mainpkg(?)});
callStatement.registerOutParameter(1, Types.INTEGER);

System.out.println("START PROCEDURe");                
callStatement.execute();
System.out.println("END PROCEDURe");

The console never print "END PROCEDURe".

P.S. The procedure takes about an hour and half

1

There are 1 best solutions below

1
On

JDBC statements will generally make the java process wait for the result (or error). If you want to let your application go on while executing your database code, use a backend thread to call the execute() method.

Also know that there may or may not be timeouts at the Database layer, so methods that do not respond after a certain while can time out; those will not return a message to the JDBC layer and thus the JDBC layer won't come back.

Look at the oracle configuration for timeout settings.