Skip to content

Commit

Permalink
JDBC ResultSet should count columns from 1 and not 0 (#32)
Browse files Browse the repository at this point in the history
The method findColumn() in a JDBC ResultSet should return 1 and not 0 for the first column.
  • Loading branch information
stefanofornari authored Oct 1, 2023
1 parent 20a2264 commit 137bd42
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ public void close() throws SQLException {
public int findColumn(final String columnLabel) throws SQLException {
checkNotClosed();
checkName(columnLabel);
return this.currentRow.getColumnDefinitions().firstIndexOf(columnLabel);
return this.currentRow.getColumnDefinitions().firstIndexOf(columnLabel)+1;
}

@Override
Expand Down Expand Up @@ -1025,7 +1025,7 @@ public Object getObject(final String columnLabel) throws SQLException {
@Override
public <T> T getObject(final String columnLabel, final Class<T> type) throws SQLException {
final int index = findColumn(columnLabel);
return getObject(index + 1, type);
return getObject(index, type);
}

@Override
Expand Down Expand Up @@ -1149,7 +1149,7 @@ public <T> T getObjectFromJson(final int columnIndex, final Class<T> type) throw
@Override
public <T> T getObjectFromJson(final String columnLabel, final Class<T> type) throws SQLException {
final int index = findColumn(columnLabel);
return getObjectFromJson(index + 1, type);
return getObjectFromJson(index, type);
}

@Override
Expand Down

0 comments on commit 137bd42

Please sign in to comment.