简体   繁体   English

执行Oracle Procedure时的Java块

[英]Java block when execute Oracle Procedure

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. 我有一个无法解决的问题,我使用ojdbc7库将Java连接到数据库Oracle11g,但在此过程结束时启动该Java应用程序时,它不会无响应地前进。 I tried to change driver ojdbc but nothing you know give me some ideas ? 我试图更改驱动程序ojdbc,但是您不知道给我一些想法吗? 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". 控制台从不打印“ END PROCEDURe”。

PS The procedure takes about an hour and half PS该过程大约需要一个半小时

JDBC statements will generally make the java process wait for the result (or error). JDBC语句通常会使Java进程等待结果(或错误)。 If you want to let your application go on while executing your database code, use a backend thread to call the execute() method. 如果要在执行数据库代码时让应用程序继续运行,请使用后端线程调用execute()方法。

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. 这些不会将消息返回到JDBC层,因此JDBC层不会回来。

Look at the oracle configuration for timeout settings. 查看oracle配置中的超时设置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM