0

I'm programing against a sybase IQ database, and get weird error when combining setFetchSize together with setObject.

  • sybase IQ server version: 16.0
  • jdbc driver: jconn4 16.0
  • java 8

Let's say we have following code snippet:

String sql = "SELECT * FROM demo.sakila.actor WHERE last_update > ? ORDER BY last_update ASC";
PreparedStatement pstmt = connection.prepareStatement(sql);
pstmt.setObject(1, "2007-1-1 00:00:00");
pstmt.setFetchSize(100);
pstmt.executeQuery();

Which ends up with error:

java.sql.SQLException: JZ0SA: Prepared Statement: Input parameter not set, index: 0.
    at com.sybase.jdbc4.jdbc.ErrorMessage.raiseError(ErrorMessage.java:762)
    at com.sybase.jdbc4.tds.TdsParam.prepareForSend(TdsParam.java:225)
    at com.sybase.jdbc4.jdbc.ParamManager.checkParams(ParamManager.java:1193)
    at com.sybase.jdbc4.tds.TdsCursor.tdsCursor(TdsCursor.java:731)
    at com.sybase.jdbc4.tds.TdsCursor.open(TdsCursor.java:321)
    at com.sybase.jdbc4.jdbc.SybStatement.executeQuery(SybStatement.java:2365)
    at com.sybase.jdbc4.jdbc.SybPreparedStatement.executeQuery(SybPreparedStatement.java:272)

Looks like it's caused by missing parameter. If I remove the line of setting fetchSize, the program works without problem.

Anyone knows is it expected behavior?

hero2008
  • 611
  • 6
  • 16

0 Answers0