• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

Problem with JDBC oracle!

 
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I code on MySQL Driver is OK, but when i transfer to oracle driver, so it not work, i am using ojdbc14.jar for connector.
Here is my source code:

Here is my error on console of eclipse ide.

Exception in thread "main" java.sql.SQLException: Invalid operation for forward only resultset : first
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:180)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:222)
at oracle.jdbc.driver.BaseResultSet.first(BaseResultSet.java:85)
at com.goodsw.performance.AlarmCountRetriever.selectCountOfMinor5Min(AlarmCountRetriever.java:68)
at com.goodsw.performance.AlarmCountRetriever.main(AlarmCountRetriever.java:123)


please help me to slove my problem
thanks very much
[ October 22, 2008: Message edited by: Tran Tuan Hung ]
 
Author
Posts: 531
Mac OS X Netbeans IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I remember that some old version of ORACLE JDBC driver do not support scrollable resultsets (ResultSet.TYPE_SCROLL_SENSITIVE) and even if you explicitly request for an scrollable resultset it gives you a none scroll sensitive resultset(ResultSet.FORWARD_ONLY).
Take a look at http://download-west.oracle.com/docs/cd/B10501_01/java.920/a96654/resltset.htm#1018228
and see whether your version of driver is affected by this limitation or not.
 
Tran Tuan Hung
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks you for your reply,
I dont know why when i replace the line:
resultSet.first() by the line: resultSet.next(), so it's work properly.
 
Ranch Hand
Posts: 1087
Oracle Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try the code below while creating the prepared statement.


Thanks,
Shailesh
 
Tran Tuan Hung
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Shailesh Chandra,
Thanks for your help,
I already try your code, so it's work properly too.
So i see that, two code below is equal result in oracle driver:
This code:

And this code:

Thanks.
[ October 24, 2008: Message edited by: Tran Tuan Hung ]
 
Shailesh Chandra
Ranch Hand
Posts: 1087
Oracle Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Tran Tuan Hung:
I already try your code, so it's work properly too


Glad to know that your code is working.

Originally posted by Tran Tuan Hung:
So i see that, two code below is equal result in oracle driver:



I am not sure If I understood you query. If you want to ask that both piece of code or same or not, then answer is no, Since your query will always result in one row so both code will behave same.

Shailesh
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic