Is there any condition under which the following statement
PreparedStatement.executeQuery()
does not return or throw an exception?
Is there any condition under which the following statement
PreparedStatement.executeQuery()
does not return or throw an exception?
It depends on the database you're using and the configured isolation level. A common default is that a SELECT will block if you're trying to select records that have been updated in another transaction that hasn't committed yet.
Are you trying to select uncommitted data? What database are you using?
Alternatively your query may just be taking a really long time. Eliminate (or confirm) this possibility by running the query through some database tool.
You may also want to call setQueryTimeout()
so the query won't block "forever".
If it hasn't returned, then it's still running your query, or is still fetching the results.
Try running the query outside of java, using a database tool of some sort, and make sure it's executing in a timely fashion.