@Override public CodecNotFoundException copy() { return new CodecNotFoundException(getMessage(), getCause(), getCqlType(), getJavaType()); } }
private static CodecNotFoundException notFound(DataType cqlType, TypeToken<?> javaType) { String msg = String.format( "Codec not found for requested operation: [%s <-> %s]", toString(cqlType), toString(javaType)); return new CodecNotFoundException(msg, cqlType, javaType); }
public void setString(int parameterIndex, String value) throws SQLException { checkNotClosed(); checkIndex(parameterIndex); try{ this.statement.setString(parameterIndex-1, value); }catch(CodecNotFoundException e){ // Big ugly hack in order to parse string representations of collections // Yes, I'm ashamed... if(e.getMessage().contains("set<")){ String itemType = e.getMessage().substring(e.getMessage().indexOf("<")+1, e.getMessage().indexOf(">")); this.statement.setSet(parameterIndex-1, Utils.parseSet(itemType, value)); }else if(e.getMessage().contains("list<")){ String itemType = e.getMessage().substring(e.getMessage().indexOf("<")+1, e.getMessage().indexOf(">")); this.statement.setList(parameterIndex-1, Utils.parseList(itemType, value)); }else if(e.getMessage().contains("map<")){ String[] kvTypes = e.getMessage().substring(e.getMessage().indexOf("<")+1, e.getMessage().indexOf(">")).replace(" ", "").split(","); this.statement.setMap(parameterIndex-1, Utils.parseMap(kvTypes[0],kvTypes[1], value)); } } }
@SuppressWarnings("unchecked") private <T> TypeCodec<T> lookupCodec(DataType cqlType, TypeToken<T> javaType) { checkNotNull(cqlType, "Parameter cqlType cannot be null"); TypeCodec<?> codec = BUILT_IN_CODECS_MAP.get(cqlType.getName()); if (codec != null && (javaType == null || codec.accepts(javaType))) { logger.trace("Returning built-in codec {}", codec); return (TypeCodec<T>) codec; } if (logger.isTraceEnabled()) logger.trace("Querying cache for codec [{} <-> {}]", toString(cqlType), toString(javaType)); try { CacheKey cacheKey = new CacheKey(cqlType, javaType); codec = cache.get(cacheKey); } catch (UncheckedExecutionException e) { if (e.getCause() instanceof CodecNotFoundException) { throw (CodecNotFoundException) e.getCause(); } throw new CodecNotFoundException(e.getCause(), cqlType, javaType); } catch (RuntimeException e) { throw new CodecNotFoundException(e.getCause(), cqlType, javaType); } catch (ExecutionException e) { throw new CodecNotFoundException(e.getCause(), cqlType, javaType); } logger.trace("Returning cached codec {}", codec); return (TypeCodec<T>) codec; }
@SuppressWarnings("cast") public void setInt(int parameterIndex, int integer) throws SQLException { checkNotClosed(); checkIndex(parameterIndex); //bindValues.put(parameterIndex, JdbcInt32.instance.decompose(integer)); try{ this.statement.setInt(parameterIndex-1, integer); }catch(CodecNotFoundException e){ if(e.getMessage().contains("Codec not found for requested operation: [varint <-> java.lang.Integer]")){ this.statement.setVarint(parameterIndex-1, BigInteger.valueOf((long)integer)); } } }
@Override public CodecNotFoundException copy() { return new CodecNotFoundException(getMessage(), getCause(), getCqlType(), getJavaType()); } }
private static CodecNotFoundException notFound(DataType cqlType, TypeToken<?> javaType) { String msg = String.format("Codec not found for requested operation: [%s <-> %s]", toString(cqlType), toString(javaType)); return new CodecNotFoundException(msg, cqlType, javaType); }
this.statement.setInt(parameterIndex-1, (Integer)object); }catch(CodecNotFoundException e){ if(e.getMessage().contains("varint")){ // sucks but works this.statement.setVarint(parameterIndex-1, BigInteger.valueOf(Long.parseLong(object.toString())));
@Override public CodecNotFoundException copy() { return new CodecNotFoundException(getMessage(), getCause(), getCqlType(), getJavaType()); } }
private static CodecNotFoundException notFound(DataType cqlType, TypeToken<?> javaType) { String msg = String.format("Codec not found for requested operation: [%s <-> %s]", toString(cqlType), toString(javaType)); return new CodecNotFoundException(msg, cqlType, javaType); }
@Override public CodecNotFoundException copy() { return new CodecNotFoundException(getMessage(), getCause(), getCqlType(), getJavaType()); } }
private static CodecNotFoundException notFound(DataType cqlType, TypeToken<?> javaType) { String msg = String.format("Codec not found for requested operation: [%s <-> %s]", toString(cqlType), toString(javaType)); return new CodecNotFoundException(msg, cqlType, javaType); }
@SuppressWarnings("unchecked") private <T> TypeCodec<T> lookupCodec(DataType cqlType, TypeToken<T> javaType) { checkNotNull(cqlType, "Parameter cqlType cannot be null"); if (logger.isTraceEnabled()) logger.trace("Querying cache for codec [{} <-> {}]", toString(cqlType), toString(javaType)); CacheKey cacheKey = new CacheKey(cqlType, javaType); try { TypeCodec<?> codec = cache.get(cacheKey); logger.trace("Returning cached codec {}", codec); return (TypeCodec<T>) codec; } catch (UncheckedExecutionException e) { if (e.getCause() instanceof CodecNotFoundException) { throw (CodecNotFoundException) e.getCause(); } throw new CodecNotFoundException(e.getCause(), cqlType, javaType); } catch (RuntimeException e) { throw new CodecNotFoundException(e.getCause(), cqlType, javaType); } catch (ExecutionException e) { throw new CodecNotFoundException(e.getCause(), cqlType, javaType); } }
@SuppressWarnings("unchecked") private <T> TypeCodec<T> lookupCodec(DataType cqlType, TypeToken<T> javaType) { checkNotNull(cqlType, "Parameter cqlType cannot be null"); TypeCodec<?> codec = BUILT_IN_CODECS_MAP.get(cqlType.getName()); if (codec != null && (javaType == null || codec.accepts(javaType))) { logger.trace("Returning built-in codec {}", codec); return (TypeCodec<T>) codec; } if (logger.isTraceEnabled()) logger.trace("Querying cache for codec [{} <-> {}]", toString(cqlType), toString(javaType)); try { CacheKey cacheKey = new CacheKey(cqlType, javaType); codec = cache.get(cacheKey); } catch (UncheckedExecutionException e) { if (e.getCause() instanceof CodecNotFoundException) { throw (CodecNotFoundException) e.getCause(); } throw new CodecNotFoundException(e.getCause(), cqlType, javaType); } catch (RuntimeException e) { throw new CodecNotFoundException(e.getCause(), cqlType, javaType); } catch (ExecutionException e) { throw new CodecNotFoundException(e.getCause(), cqlType, javaType); } logger.trace("Returning cached codec {}", codec); return (TypeCodec<T>) codec; }
@SuppressWarnings("unchecked") private <T> TypeCodec<T> lookupCodec(DataType cqlType, TypeToken<T> javaType) { checkNotNull(cqlType, "Parameter cqlType cannot be null"); if (logger.isTraceEnabled()) logger.trace("Querying cache for codec [{} <-> {}]", toString(cqlType), toString(javaType)); CacheKey cacheKey = new CacheKey(cqlType, javaType); try { TypeCodec<?> codec = cache.get(cacheKey); logger.trace("Returning cached codec {}", codec); return (TypeCodec<T>) codec; } catch (UncheckedExecutionException e) { if (e.getCause() instanceof CodecNotFoundException) { throw (CodecNotFoundException) e.getCause(); } throw new CodecNotFoundException(e.getCause(), cqlType, javaType); } catch (RuntimeException e) { throw new CodecNotFoundException(e.getCause(), cqlType, javaType); } catch (ExecutionException e) { throw new CodecNotFoundException(e.getCause(), cqlType, javaType); } }