adejanovski / cassandra-jdbc-wrapper

A JDBC wrapper for the Datastax Java Driver for Cassandra
Apache License 2.0
53 stars 36 forks source link

CodecNotFoundException because an off-by-one error #18

Open lucasgp opened 7 years ago

lucasgp commented 7 years ago

When calling method com.github.adejanovski.cassandra.jdbc.CassandraResultSet#getTimestamp(int, java.util.Calendar) I get a CodecNotFoundException.

This error is caused because this method delegates to com.github.adejanovski.cassandra.jdbc.CassandraResultSet#getTimestamp(int) passing a wrong value in the index parameter.

public Timestamp getTimestamp(int index) throws SQLException {
    this.checkIndex(index);
    java.util.Date date = this.currentRow.getTimestamp(index - 1);
    return date == null?null:new Timestamp(this.currentRow.getTimestamp(index - 1).getTime());
}

public Timestamp getTimestamp(int index, Calendar calendar) throws SQLException {
    this.checkIndex(index);
    java.util.Date date = this.currentRow.getTimestamp(index - 1);
    return date == null?null:this.getTimestamp(index - 1);
}

If the method getTimestamp(int, java.util.Calendar) receives 2 in the index param, it would then call getTimestamp(int) with index - 1. This causes the call to this.currentRow.getTimestamp(index - 1) being done over the previous column, not the current one.