Exception on resultset

View: New views
4 Messages — Rating Filter:   Alert me  

Exception on resultset

by Rahul-36 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


IS there a way for checking out the resultset for size.

I am doing something like this


select.from(TABLE_BOOKED_ROOMS).where("ROOM_room_id = " + room_id +
"");


        String result = (String)manager.executeQuery(select, new
DbResultSetHandler() {
                public Object concludeResults(DbResultSet resultset)
                throws SQLException
                {


                resultset.next();

                return resultset.getString("bookedroom_id");
                }
        });

However if booked_room table dosnt have any record for the given query
then it throws SQl exception java.sql.SQLException: Illegal operation
on empty result set.

Is there any way of checking out the size of resultset or may be other
way of doing it?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "rife-users" group.
To post to this group, send email to rife-users@...
To unsubscribe from this group, send email to rife-users+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/rife-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Exception on resultset

by Geert Bevin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


http://rifers.org/docs/api/com/uwyn/rife/database/DbResultSet.html#hasResultRows()

On 15 Apr 2009, at 11:04, Rahul wrote:

>
> IS there a way for checking out the resultset for size.
>
> I am doing something like this
>
>
> select.from(TABLE_BOOKED_ROOMS).where("ROOM_room_id = " + room_id +
> "");
>
>
> String result = (String)manager.executeQuery(select, new
> DbResultSetHandler() {
>        public Object concludeResults(DbResultSet resultset)
>        throws SQLException
>        {
>
>
>         resultset.next();
>
>         return resultset.getString("bookedroom_id");
>        }
> });
>
> However if booked_room table dosnt have any record for the given query
> then it throws SQl exception java.sql.SQLException: Illegal operation
> on empty result set.
>
> Is there any way of checking out the size of resultset or may be other
> way of doing it?
> >

--
Geert Bevin
Terracotta - http://www.terracotta.org
Uwyn "Use what you need" - http://uwyn.com
RIFE Java application framework - http://rifers.org
Flytecase Band - http://flytecase.be
Music and words - http://gbevin.com


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "rife-users" group.
To post to this group, send email to rife-users@...
To unsubscribe from this group, send email to rife-users+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/rife-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Exception on resultset

by Rahul-36 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


yes .. got it...

thanks

On Apr 15, 2:07 pm, Geert Bevin <gbe...@...> wrote:

> http://rifers.org/docs/api/com/uwyn/rife/database/DbResultSet.html#ha...()
>
> On 15 Apr 2009, at 11:04, Rahul wrote:
>
>
>
>
>
> > IS there a way for checking out the resultset for size.
>
> > I am doing something like this
>
> > select.from(TABLE_BOOKED_ROOMS).where("ROOM_room_id = " + room_id +
> > "");
>
> >    String result = (String)manager.executeQuery(select, new
> > DbResultSetHandler() {
> >            public Object concludeResults(DbResultSet resultset)
> >            throws SQLException
> >            {
>
> >                    resultset.next();
>
> >                    return resultset.getString("bookedroom_id");
> >            }
> >    });
>
> > However if booked_room table dosnt have any record for the given query
> > then it throws SQl exception java.sql.SQLException: Illegal operation
> > on empty result set.
>
> > Is there any way of checking out the size of resultset or may be other
> > way of doing it?
>
> --
> Geert Bevin
> Terracotta -http://www.terracotta.org
> Uwyn "Use what you need" -http://uwyn.com
> RIFE Java application framework -http://rifers.org
> Flytecase Band -http://flytecase.be
> Music and words -http://gbevin.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "rife-users" group.
To post to this group, send email to rife-users@...
To unsubscribe from this group, send email to rife-users+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/rife-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Exception on resultset

by Joshua Hansen :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hi Rahul,

Geert already answered your question (i.e. "Use
DbResultSet.hasResultRows()), so you're good there.

As an extra tip, instead of using:
------
select.from(TABLE_BOOKED_ROOMS).where("ROOM_room_id = " + room_id + "");
------
you should consider using:
------
select.from(TABLE_BOOKED_ROOMS).where("ROOM_room_id", "=", room_id);
------

This way your code will be safe from an SQL injection attack.  If
'room_id' is an int or Integer, this is less of an issue, but it's still
a good default practice, and it's critical when you are using a String. :)

Josh
--
Joshua Hansen
Up Bear Enterprises
(541) 760-7685


Rahul wrote:

> IS there a way for checking out the resultset for size.
>
> I am doing something like this
>
>
> select.from(TABLE_BOOKED_ROOMS).where("ROOM_room_id = " + room_id +
> "");
>
>
> String result = (String)manager.executeQuery(select, new
> DbResultSetHandler() {
>        public Object concludeResults(DbResultSet resultset)
>        throws SQLException
>        {
>
>
>         resultset.next();
>
>         return resultset.getString("bookedroom_id");
>        }
> });
>
> However if booked_room table dosnt have any record for the given query
> then it throws SQl exception java.sql.SQLException: Illegal operation
> on empty result set.
>
> Is there any way of checking out the size of resultset or may be other
> way of doing it?
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "rife-users" group.
To post to this group, send email to rife-users@...
To unsubscribe from this group, send email to rife-users+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/rife-users?hl=en
-~----------~----~----~----~------~----~------~--~---

 
 
 
Google
rifers.org web