[#5901] Bind variable index should be logged in stack trace when there is a JDBC data type problem
This commit is contained in:
parent
5cd1821ba8
commit
9d83278088
@ -1595,6 +1595,7 @@ final class CursorImpl<R extends Record> implements Cursor<R> {
|
||||
ctx.record(record);
|
||||
listener.recordStart(ctx);
|
||||
|
||||
try {
|
||||
|
||||
|
||||
|
||||
@ -1621,6 +1622,11 @@ final class CursorImpl<R extends Record> implements Cursor<R> {
|
||||
if (intern[i])
|
||||
record.intern0(i);
|
||||
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}
|
||||
ctx.record(record);
|
||||
listener.recordEnd(ctx);
|
||||
|
||||
@ -1632,24 +1638,31 @@ final class CursorImpl<R extends Record> implements Cursor<R> {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private final <T> void setValue(AbstractRecord record, Field<T> field, int index) throws SQLException {
|
||||
T value;
|
||||
try {
|
||||
T value;
|
||||
|
||||
if (field instanceof RowField) {
|
||||
Field<?>[] emulatedFields = ((RowField<?, ?>) field).emulatedFields();
|
||||
if (field instanceof RowField) {
|
||||
Field<?>[] emulatedFields = ((RowField<?, ?>) field).emulatedFields();
|
||||
|
||||
value = (T) Tools.newRecord(true, RecordImpl.class, emulatedFields, ctx.configuration())
|
||||
.operate(new CursorRecordInitialiser(emulatedFields, offset + index));
|
||||
value = (T) Tools.newRecord(true, RecordImpl.class, emulatedFields, ctx.configuration())
|
||||
.operate(new CursorRecordInitialiser(emulatedFields, offset + index));
|
||||
|
||||
offset += emulatedFields.length - 1;
|
||||
}
|
||||
else {
|
||||
rsContext.index(offset + index + 1);
|
||||
field.getBinding().get((BindingGetResultSetContext<T>) rsContext);
|
||||
value = (T) rsContext.value();
|
||||
offset += emulatedFields.length - 1;
|
||||
}
|
||||
else {
|
||||
rsContext.index(offset + index + 1);
|
||||
field.getBinding().get((BindingGetResultSetContext<T>) rsContext);
|
||||
value = (T) rsContext.value();
|
||||
}
|
||||
|
||||
record.values[index] = value;
|
||||
record.originals[index] = value;
|
||||
}
|
||||
|
||||
record.values[index] = value;
|
||||
record.originals[index] = value;
|
||||
// [#5901] Improved error logging, mostly useful when there are some data type conversion errors
|
||||
catch (Exception e) {
|
||||
throw new SQLException("Error while reading field: " + field + ", at JDBC index: " + (offset + index + 1), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -53,9 +53,16 @@ final class DefaultBindContext extends AbstractBindContext {
|
||||
@Override
|
||||
@SuppressWarnings({ "unchecked" })
|
||||
protected final BindContext bindValue0(Object value, Field<?> field) throws SQLException {
|
||||
((Field<Object>) field).getBinding().set(
|
||||
new DefaultBindingSetStatementContext<Object>(configuration(), data(), stmt, nextIndex(), value)
|
||||
);
|
||||
int nextIndex = nextIndex();
|
||||
|
||||
try {
|
||||
((Field<Object>) field).getBinding().set(
|
||||
new DefaultBindingSetStatementContext<Object>(configuration(), data(), stmt, nextIndex, value)
|
||||
);
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new SQLException("Error while writing value at JDBC bind index: " + nextIndex ,e);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user