Forums Register Login

Java Prepared Statement execution not returning any data

+Pie Number of slices to send: Send
I have a prepared statement with a simple query...my problem is that it does not return any data. For example,



If I use the same sql but with inline parameters...it returns me the data I expect. For example,



There was a similar post at experts-exchange but I have to pay to see the solution.

Has anybody encountered this before?

Thanks.
+Pie Number of slices to send: Send
Hi Dennis,

I've not encountered this problem, but can you give a real example and state which database and JDBC driver you're using?

Jules
+Pie Number of slices to send: Send
Dennis,
You actually don't have to sign up to see the solution. Just keep scrolling down past all the ads and you see the answers.
+Pie Number of slices to send: Send
OK, so to summarise:
  • Ensure that you're not getting any exceptions, e.g. ones that you're ignoring with code like catch(Exception e) { }
  • Ensure that your SQL returns rows when executed in the database directly, i.e. outside Java
  • Ensure that you're connecting using the same credentials (i.e. machine, database, user/schema, etc.)
  • Ensure that the data you're trying to read has been committed if it was added in a different session. Alternatively set the transaction isolation in Java for dirty reads using code like con.setTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED); WARNING: do this only if you mean it and know what you're doing

  • Hope that helps.

    Jules
    Get meta with me! What pursues us is our own obsessions! But not this tiny ad:
    a bit of art, as a gift, the permaculture playing cards
    https://gardener-gift.com


    reply
    reply
    This thread has been viewed 1459 times.
    Similar Threads
    How to check if Radio Buttons and Checkboxes have data
    need some help
    How to Escape single quotes with PreparedStatment while using PostGresql?
    Does the TransactionAttributeType Required has an impact on JDBC-calls?
    Cursor Inside if is it Possible?
    More...

    All times above are in ranch (not your local) time.
    The current ranch time is
    Apr 16, 2024 07:37:18.