sql excepton: invalid operation for the current cursor position.

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)
jeff1919Asked:
Who is Participating?
 
objectsCommented:
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
 
YagantappaCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.