Don Branson
Don Branson

Reputation: 13707

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.

Upvotes: 5

Views: 2582

Answers (1)

akf
akf

Reputation: 39495

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.

Upvotes: 4

Related Questions