@@ -47,6 +47,8 @@ public class ArrayResultSet implements ResultSet {
4747
4848 private static final ClickHouseColumn INDEX_COLUMN = ClickHouseColumn .of ("INDEX" , ClickHouseDataType .UInt32 , false , 0 , 0 );
4949 private static final String VALUE_COLUMN = "VALUE" ;
50+ private static final ValueConverters defaultValueConverters = new ValueConverters ();
51+
5052 private int fetchDirection = ResultSet .FETCH_FORWARD ;
5153 private int fetchSize = 0 ;
5254 private boolean wasNull = false ;
@@ -71,14 +73,13 @@ public ArrayResultSet(Object array, ClickHouseColumn column) {
7173 , "" , "" , "" , JdbcUtils .DATA_TYPE_CLASS_MAP );
7274 this .componentDataType = valueColumn .getDataType ();
7375 this .defaultClass = JdbcUtils .DATA_TYPE_CLASS_MAP .get (componentDataType );
74- ValueConverters converters = new ValueConverters ();
75- indexConverterMap = converters .getConvertersForType (Integer .class );
76+ indexConverterMap = defaultValueConverters .getConvertersForType (Integer .class );
7677 if (this .length > 0 ) {
7778 Class <?> itemClass = array .getClass ().getComponentType ();
7879 if (itemClass == null ) {
7980 itemClass = java .lang .reflect .Array .get (array , 0 ).getClass ();
8081 }
81- converterMap = converters .getConvertersForType (itemClass );
82+ converterMap = defaultValueConverters .getConvertersForType (itemClass );
8283 } else {
8384 // empty array - no values to convert
8485 converterMap = null ;
@@ -127,7 +128,12 @@ private Object getValueAsObject(int columnIndex, Class<?> type, Object defaultVa
127128 // if there is something to convert. type == Object.class means no conversion
128129 Function <Object , Object > converter = valueConverterMap .get (type );
129130 if (converter != null ) {
130- value = converter .apply (value );
131+ try {
132+ value = converter .apply (value );
133+ } catch (Exception e ) {
134+ throw new SQLException ("Failed to convert value of " + value .getClass () + " to " + type ,
135+ ExceptionUtils .SQL_STATE_DATA_EXCEPTION , e );
136+ }
131137 } else {
132138 throw new SQLException ("Value of " + value .getClass () + " cannot be converted to " + type );
133139 }
0 commit comments