/** * Get {@link SnappyType} for given JDBC {@link Types}. */ public static SnappyType getThriftSQLType(int jdbcType) { return getThriftSQLType(jdbcType, false); }
/** * {@inheritDoc} */ @Override public void registerOutParameter(int parameterIndex, int sqlType) throws SQLException { OutputParameter outParam = new OutputParameter( Converters.getThriftSQLType(sqlType)); getOutputParamsSet().put(parameterIndex, outParam); }
/** * {@inheritDoc} */ @Override public boolean supportsConvert(int fromType, int toType) throws SQLException { this.conn.lock(); try { initServiceMetaData(); Set<SnappyType> conversions = this.serviceMetaData.getSupportedCONVERT() .get(Converters.getThriftSQLType(fromType)); return conversions != null && conversions.contains(Converters.getThriftSQLType(toType)); } finally { this.conn.unlock(); } }
/** * {@inheritDoc} */ @Override public void registerOutParameter(int parameterIndex, int sqlType, int scale) throws SQLException { OutputParameter outParam = new OutputParameter( Converters.getThriftSQLType(sqlType)).setScale(scale); getOutputParamsSet().put(parameterIndex, outParam); }
/** * {@inheritDoc} */ @Override public void registerOutParameter(int parameterIndex, int sqlType, String typeName) throws SQLException { OutputParameter outParam = new OutputParameter( Converters.getThriftSQLType(sqlType)).setTypeName(typeName); getOutputParamsSet().put(parameterIndex, outParam); }
/** * {@inheritDoc} */ @Override public final void setNull(int parameterIndex, int sqlType, String typeName) throws SQLException { checkValidParameterIndex(parameterIndex); // ignore typeName this.paramsList.setNull(parameterIndex - 1, Converters.getThriftSQLType(sqlType).getValue()); }
/** * {@inheritDoc} */ @Override public ResultSet getUDTs(String catalog, String schemaPattern, String typeNamePattern, int[] types) throws SQLException { this.conn.lock(); try { List<SnappyType> sqlTypes = null; if (types != null) { // convert to thrift SQL types sqlTypes = new ArrayList<>(types.length); for (int type : types) { sqlTypes.add(Converters.getThriftSQLType(type)); } } RowSet rs = this.service.getUDTs( new ServiceMetaDataArgs() .setDriverType(ClientConfiguration.DRIVER_TYPE) .setSchema(schemaPattern).setTypeName(typeNamePattern), sqlTypes); return new ClientResultSet(this.conn, this.metaAttrs, rs); } catch (SnappyException se) { throw ThriftExceptionUtil.newSQLException(se); } finally { this.conn.unlock(); } }
for (int toType : allTypes) { if (dmd.supportsConvert(fromType, toType)) { supportedConverts.add(Converters.getThriftSQLType(toType)); convertMap.put(Converters.getThriftSQLType(fromType), supportedConverts);
pmType = pmd.getParameterType(paramPosition); ColumnDescriptor pmDesc = new ColumnDescriptor(); type = Converters.getThriftSQLType(pmType); mode = pmd.getParameterMode(paramPosition); switch (mode) {
TypeId typeId = dtd.getTypeId(); jdbcType = typeId.getJDBCTypeId(); type = Converters.getThriftSQLType(jdbcType, useStringForDecimal); ColumnDescriptor columnDesc = new ColumnDescriptor(); columnName = rcd.getName(); columnDesc.setType(Converters.getThriftSQLType(jdbcType, useStringForDecimal)); columnDesc.setPrecision((short)rsmd.getPrecision(colIndex));