dev@glassfish.java.net

Re: setFirstResult in conjunction with setMaxResults returns too much results

From: Lance J. Andersen <Lance.Andersen_at_Sun.COM>
Date: Fri, 05 Jan 2007 16:36:59 -0500

Hi Markus,

> Well there is one bug already as it should throw a SQLException not
> OperationNotSupportedException
>
> You lost me on the :
>
> The driver needs an explicit "CONCUR_*"
>
> Can you please explain this a little further, what is the statement
> you were expecting to work?

Are you referring to:

PreparedStatement stmt = conn.prepareStatement("select * from mytable",
java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE);

This is not valid and i suspect it is being executed as:

prepareStatment(String sql, int autoGeneratedKeys)

Which will result in an error as the value for
java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE is out of range for this method.


The valid Connection.prepareStatement methods are:

| PreparedStatement
<http://java.sun.com/j2se/1.5.0/docs/api/java/sql/PreparedStatement.html>|
        |*prepareStatement
<http://java.sun.com/j2se/1.5.0/docs/api/java/sql/Connection.html#prepareStatement%28java.lang.String%29>*(String
<http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html> sql)|
          Creates a |PreparedStatement| object for sending parameterized
SQL statements to the database.
| PreparedStatement
<http://java.sun.com/j2se/1.5.0/docs/api/java/sql/PreparedStatement.html>|
        |*prepareStatement
<http://java.sun.com/j2se/1.5.0/docs/api/java/sql/Connection.html#prepareStatement%28java.lang.String,%20int%29>*(String
<http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html> sql,
int autoGeneratedKeys)|
          Creates a default |PreparedStatement| object that has the
capability to retrieve auto-generated keys.
| PreparedStatement
<http://java.sun.com/j2se/1.5.0/docs/api/java/sql/PreparedStatement.html>|
        |*prepareStatement
<http://java.sun.com/j2se/1.5.0/docs/api/java/sql/Connection.html#prepareStatement%28java.lang.String,%20int%5B%5D%29>*(String
<http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html> sql,
int[] columnIndexes)|
          Creates a default |PreparedStatement| object capable of
returning the auto-generated keys designated by the given array.
| PreparedStatement
<http://java.sun.com/j2se/1.5.0/docs/api/java/sql/PreparedStatement.html>|
        |*prepareStatement
<http://java.sun.com/j2se/1.5.0/docs/api/java/sql/Connection.html#prepareStatement%28java.lang.String,%20int,%20int%29>*(String
<http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html> sql,
int resultSetType, int resultSetConcurrency)|
          Creates a |PreparedStatement| object that will generate
|ResultSet| objects with the given type and concurrency.
| PreparedStatement
<http://java.sun.com/j2se/1.5.0/docs/api/java/sql/PreparedStatement.html>|
        |*prepareStatement
<http://java.sun.com/j2se/1.5.0/docs/api/java/sql/Connection.html#prepareStatement%28java.lang.String,%20int,%20int,%20int%29>*(String
<http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html> sql,
int resultSetType, int resultSetConcurrency, int resultSetHoldability)|
          Creates a |PreparedStatement| object that will generate
|ResultSet| objects with the given type, concurrency, and holdability.
| PreparedStatement
<http://java.sun.com/j2se/1.5.0/docs/api/java/sql/PreparedStatement.html>|
        |*prepareStatement
<http://java.sun.com/j2se/1.5.0/docs/api/java/sql/Connection.html#prepareStatement%28java.lang.String,%20java.lang.String%5B%5D%29>*(String
<http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html> sql,
String
<http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html>[] columnNames)|

          Creates a default |PreparedStatement| object capable of
returning the auto-generated keys designated by the given array.



regards
Lance