Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Concurrent queries on a given JDBC connection?

I'm seeing OraclePreparedStatement executeQuery() exhibit serialization. That is, I have two queries that I want to run concurrently against an Oracle database, using the same connection. However, the OraclePreparedStatement seems to explicitly prohibit concurrent queries.

My question is: Is this serialization a necessary artifact of running both queries on the same connection, or is this configurable?

I've tried setting readOnly to true for the duration of the two queries, but they still serialize.

like image 200
Don Branson Avatar asked Oct 15 '22 15:10

Don Branson


1 Answers

I believe that Oracle's Connection class methods are synchronized. see this api description. This would then be an artifact of using the same connection, and not a configurable property. If you need to get around this limitation, you can either use 2 connections or look into connection pooling if you want a more flexible solution.

like image 192
akf Avatar answered Oct 18 '22 22:10

akf