Tuesday, March 4, 2014

java.sql.SQLException: Invalid operation for forward only resultset : isLast

The isLast(), last(), beforeFirst(), and other methods in the ResultSet class that use the absolute index are available only after the ResultSet is set tResultSet.TYPE_SCROLL_INSENSITIVE. Otherwise it throws "Invalid operation for forward only resultset : <method name>" exception.

To fix this type of exception, do one of the followings.

1. Statement statement = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);

       ResultSet rs = statement.executeQuery(sql);

2. PreparedStatement statement = conn.prepareStatement(sql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);

      ResultSet rs = statement.executeQuery();

------------------------------------------------------------------------------------------------------------

          
                        
If you have ever asked yourself these questions, this is the book for you. What is the meaning of life? Why do people suffer? What is in control of my life? Why is life the way it is? How can I stop suffering and be happy? How can I have a successful life? How can I have a life I like to have? How can I be the person I like to be? How can I be wiser and smarter? How can I have good and harmonious relations with others? Why do people meditate to achieve enlightenment? What is the true meaning of spiritual practice? Why all beings are one? Read the book free here.

4 comments:

  1. Hi Joy. Please write on when i can use dual table.

    Thanks, Selena

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. Selena, Here is the link.

    http://flyingjxswithjava.blogspot.com/2014/03/the-oracle-dual-table.html

    ReplyDelete