I am developing a PL/SQL stored procedure which inserts rows into a table. The procedure potentially writes tens of thousands of rows per each call which could take minutes to complete. I’m also developing another procedure which queries the V$SESSION_LONGOPS view for information such as how much work has been done and approximately how much time remains for processing so that I could use the information for a progress bar.
Here, I’m not clear about how Oracle does things. I am going to call two procedures from a Java application and these procedures will have to run concurrently. To achieve that behaviour, do have have to use two connections to Oracle? Or is one connection enough? Does multi-threading automatically happen in an Oracle session if multiple connections are used?
I’m using Hibernate to connect to the database. And I have a few questions for the application too. If I send two queries to the database from two threads, does Hibernate use two connections from its connection pool to send the queries? The second query (which will be used by the progress bar) will run repeatedly while the first query (which performs the inserts) is still executing.
Thanks in advance.
A Hibernate session is not thread-safe, and so each thread must have its own session. Each session uses a JDBC connection, so both sessions will each get a different JDBC connection from the pool.
And of course, Oracle allows concurrent access to the database using two connections, else every app out there would have serious performance problems.