aspose file tools*
The moose likes JDBC and the fly likes Problem with JDBC oracle! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Problem with JDBC oracle!" Watch "Problem with JDBC oracle!" New topic
Author

Problem with JDBC oracle!

Tran Tuan Hung
Ranch Hand

Joined: Apr 08, 2007
Posts: 59
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 ]
Masoud Kalali
Author
Ranch Hand

Joined: Jul 08, 2004
Posts: 531

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.


Masoud Kalali
Software Engineer - My Weblog - GlassFish Security
Tran Tuan Hung
Ranch Hand

Joined: Apr 08, 2007
Posts: 59
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.
Shailesh Chandra
Ranch Hand

Joined: Aug 13, 2004
Posts: 1081

Try the code below while creating the prepared statement.


Thanks,
Shailesh


Gravitation cannot be held responsible for people falling in love ~ Albert Einstein
Tran Tuan Hung
Ranch Hand

Joined: Apr 08, 2007
Posts: 59
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

Joined: Aug 13, 2004
Posts: 1081

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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Problem with JDBC oracle!