vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| I have seen the problem reported in various news groups going back to 1999 (Deja.News). Does anyone know if it's been fixed yet. There appears to be no solution on the web. I call a simple stored procedure from a java program and use the following line: protected static final String GET_ACCOUNTS_PROC = "{call ACCOUNT.GET_ACCOUNTS_PROC_ALL(?,?)}"; cs = connection.prepareCall(GET_ACCOUNTS_PROC, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); cs.execute(); rset = (ResultSet) cs.getObject(2); rset.first(); throws a SQL Exception: Invalid operation for forward only resultset : first Ridiculous that I can't do this. Someone please tell me I'm wrong. oracle 9 driver: ojdbc14.jar --> jdbc |
| |||
| hikemike@gmail.com wrote: > I have seen the problem reported in various news groups going back to > 1999 (Deja.News). Does anyone know if it's been fixed yet. There > appears to be no solution on the web. > > I call a simple stored procedure from a java program and use the > following line: > > protected static final String GET_ACCOUNTS_PROC = "{call > ACCOUNT.GET_ACCOUNTS_PROC_ALL(?,?)}"; > > cs = connection.prepareCall(GET_ACCOUNTS_PROC, > ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); > > cs.execute(); > rset = (ResultSet) cs.getObject(2); > rset.first(); > > throws a SQL Exception: > > Invalid operation for forward only resultset : first > > Ridiculous that I can't do this. Someone please tell me I'm wrong. > > oracle 9 driver: ojdbc14.jar --> jdbc Well, in your case, the call to first() is identical semantically to if you simply called next(), so maybe you can just do that. If the driver wanted to be clever and friendly, it maybe could make it's scrollable-resultset methods do what you want in the rare cases when they can, such as if you were on the second-to-last row, last() would be the same as next(), or if you were at the 7th row and called absolute(8) it would mean the same as next() etc. That would just be too tricky for not much real user benefit, so I wouldn't hold up too many hopes for it. Just stick to the simple JDBC 1.0 methods that will completely process the result set type you asked for: cs.execute(); rset = (ResultSet) cs.getObject(2); if (rset.next()) ... // do what you want with the first row Note that your original code depends on the result set not being empty... You can't go wrong with the standard: cs.execute(); rset = (ResultSet) cs.getObject(2); while(rset.next()) { do whatever. You can track whether this is the first row if that's important } rset.close(); HTH, Joe Weinstein at BEA Systems |
| ||||
| I don't believe the 9i JDBC drivers fully support scrollable result sets. At some point they added some scrolling capability (9.X?) but I believe it was initially on the client side only, so would likely be a performance hog if used. --Peter hikemike@gmail.com wrote: > I have seen the problem reported in various news groups going back to > 1999 (Deja.News). Does anyone know if it's been fixed yet. There > appears to be no solution on the web. > > I call a simple stored procedure from a java program and use the > following line: > > protected static final String GET_ACCOUNTS_PROC = "{call > ACCOUNT.GET_ACCOUNTS_PROC_ALL(?,?)}"; > > cs = connection.prepareCall(GET_ACCOUNTS_PROC, > ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); > > cs.execute(); > rset = (ResultSet) cs.getObject(2); > rset.first(); > > throws a SQL Exception: > > Invalid operation for forward only resultset : first > > Ridiculous that I can't do this. Someone please tell me I'm wrong. > > oracle 9 driver: ojdbc14.jar --> jdbc > |