#1296 Jdbc Batch Selects doesn't work

closed-invalid
Fred Toussi
jdbc (172)
1
2013-04-12
2013-04-12
No

When executing a batch of select queries, HSQLDB 2.2.9 reports an error:
"java.sql.SQLException: statement does not generate a row count"

The problem can be reproduced with the Junit Test in the attachment, or with the

Discussion

  • Test case for reproduce the problem

     
  • Jdbc Statement.executeBatch() states that queries not returning rows affected returns "SUCCESS_NO_INFO". Thus, I was expecting that select queries can be batched.
    (http://docs.oracle.com/javase/1.5.0/docs/api/java/sql/Statement.html#executeBatch())

     
  • Fred Toussi
    Fred Toussi
    2013-04-12

    Batch statements are for INSERT and UPDATE, and possibly other statements that modify the data.

    getMoreResults() is used with non-batched statements that return multiple ResultSet objects. These are calls to stored procedure that return several results.

    The JavaDoc for Java 6 and later adds the following clarification for addBatch():
    .
    Parameters: sql - typically this is a SQL INSERT or UPDATE statement (:JDBC4 modified)

     
  • Fred Toussi
    Fred Toussi
    2013-04-12

    • assigned_to: nobody --> fredt
    • priority: 5 --> 1
    • status: open --> closed-invalid