public static void buildPrepareStatement()

in java/clickhouse-client/src/main/java/com/epam/deltix/clickhouse/util/SelectQueryHelper.java [217:273]


    public static void buildPrepareStatement(List<SelectParam> params, PreparedStatement pstmt) throws SQLException {
        if (params != null) {
            int index = 1;
            for (SelectParam selectParam : params) {
                switch (selectParam.getFilterType()) {
                    case ENUM8:
                        pstmt.setString(index++, ((Enum8Param) selectParam).getEnumValue());
                        break;
                    case ENUM16:
                        pstmt.setString(index++, ((Enum16Param) selectParam).getEnumValue());
                        break;
                    case STRING:
                    case FIXED_STRING:
                        pstmt.setString(index++, ((StringParam) selectParam).getStringValue());
                        break;
                    case UINT8:
                    case UINT16:
                    case UINT32:
                    case UINT64:
                        pstmt.setLong(index++, ((UInt64Param) selectParam).getUint64Value());
                        break;
                    case INT8:
                    case INT16:
                    case INT32:
                    case INT64:
                        pstmt.setLong(index++, ((Int64Param) selectParam).getInt64Value());
                        break;
                    case FLOAT32:
                    case FLOAT64:
                        pstmt.setDouble(index++, ((Float64Param) selectParam).getFloat64Value());
                        break;

                    case DECIMAL:
                    case DECIMAL32:
                    case DECIMAL64:
                    case DECIMAL128:
                        pstmt.setBigDecimal(index++, ((DecimalParam) selectParam).getDecimalValue());
                        break;

                    case DATE:
                        Date sqlDate = Date.valueOf(((DateParam) selectParam).getDateValue());
                        pstmt.setDate(index++, sqlDate);
                        break;
                    case DATE_TIME:
                    case DATE_TIME64:
                        // @MS This is a work-around for lack of support of new DateTime64 fields in clickhouse client
                        // We have to format string manually to preserve millisecond resolution
                        //pstmt.setTimestamp(index++, new Timestamp(((DateTimeParam) selectParam).getDateTimeValue().toEpochMilli()));
                        pstmt.setString(index++, CodecUtil.TIMESTAMP_FORMAT_MS.format(new java.util.Date(((DateTimeParam) selectParam).getDateTimeValue().toEpochMilli())));
                        break;

                    default:
                        throw unsupportedFilterException(selectParam.getFilterType(), selectParam.getValue().toString());
                }
            }
        }
    }