?
Solved

sql excepton: invalid operation for the current cursor position.

Posted on 2006-06-08
2
Medium Priority
?
2,435 Views
Last Modified: 2012-06-27
The following code generates sql excepton: invalid operation for the current cursor position.

Connection conn = getConnection();
String query = "SELECT * FROM tekms_document where doc_code= ? and doc_child=?";
PreparedStatement pstmt = conn.prepareStatement(query);
System.out.println("before resultset");
pstmt.setString(1, doc_code);
pstmt.setString(2, doc_child);
System.out.println("before create result set");
ResultSet rs = pstmt.executeQuery();
rs.next();       
System.out.println("after rs.next()");
stream = rs.getBinaryStream(6);
String code = rs.getString(1);
String child =rs.getString(4);
System.out.println("doc_code: "+ code);
System.out.println("doc_child: "+ child);

The stacktrace is:

[6/8/06 17:38:36:812 CST] 4b3b256e SystemOut     O before create result set
[6/8/06 17:38:36:828 CST] 4b3b256e SystemOut     O after rs.next()
[6/8/06 17:38:36:828 CST] 4b3b256e SystemErr     R java.sql.SQLException: [IBM][SQLServer JDBC Driver]Invalid operation for the current cursor position.
[6/8/06 17:38:36:828 CST] 4b3b256e SystemErr     R       at com.ibm.websphere.jdbc.base.BaseExceptions.createException(Unknown Source)
[6/8/06 17:38:36:828 CST] 4b3b256e SystemErr     R       at com.ibm.websphere.jdbc.base.BaseExceptions.getException(Unknown Source)
[6/8/06 17:38:36:828 CST] 4b3b256e SystemErr     R       at com.ibm.websphere.jdbc.base.BaseResultSet.validateCursorPosition(Unknown Source)
[6/8/06 17:38:36:828 CST] 4b3b256e SystemErr     R       at com.ibm.websphere.jdbc.base.BaseResultSet.getBinaryStream(Unknown Source)
[6/8/06 17:38:36:828 CST] 4b3b256e SystemErr     R       at com.ibm.websphere.jdbcx.base.BaseResultSetWrapper.getBinaryStream(Unknown Source)
[6/8/06 17:38:36:828 CST] 4b3b256e SystemErr     R       at com.ibm.ws.rsadapter.jdbc.WSJdbcResultSet.getBinaryStream(WSJdbcResultSet.java:590)
0
Comment
Question by:jeff1919
2 Comments
 
LVL 92

Accepted Solution

by:
objects earned 1000 total points
ID: 16859872
if (rs.next()) {
   System.out.println("after rs.next()");
   stream = rs.getBinaryStream(6);
   String code = rs.getString(1);
   String child =rs.getString(4);
   System.out.println("doc_code: "+ code);
   System.out.println("doc_child: "+ child);
}
0
 
LVL 4

Expert Comment

by:Yagantappa
ID: 16859917
Hai,
   I think there is a problem with line stream = rs.getBinaryStream(6);
Please let us know what are the columns present in the table "tekms_document" and there corresponding data types.
Yag
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses
Course of the Month16 days, 22 hours left to enroll

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question