dev@glassfish.java.net

Re: setFirstResult in conjunction with setMaxResults returns too much results

From: Markus KARG <markus.karg_at_gmx.net>
Date: Sat, 06 Jan 2007 16:07:20 +0100

Lance,

thank you for your explanation. Yes, indeed I was not aware of the
two-parameter version of prepareStatement, which in fact is not the
concurrency level but the generation option. Sorry, I should read the
API more carefully. :-)

For the UnsupportedOperationException, I have filed a bug report with
Sybase's web tracker.

Thanks for all
Markus

Tom Ware schrieb:
> Appolgies... As I mentioned when I sent the example, I just hacked
> together some example code from an old example I had lying around. I
> only looked very briefly at the prepareStatement() javadoc and must
> have missed an argument.
>
> Lance is right about the correct API.
>
> -Tom
>
> Lance J. Andersen wrote:
>
>> 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
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>