public class JdbcCommon extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
JdbcCommon.AvroConversionOptions |
static interface |
JdbcCommon.ResultSetRowCallback
An interface for callback methods which allows processing of a row during the convertToAvroStream() processing.
|
| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_PRECISION_VALUE |
static int |
DEFAULT_SCALE_VALUE |
static Pattern |
LONG_PATTERN |
static String |
MASKED_LOG_VALUE |
static int |
MAX_DIGITS_IN_BIGINT |
static int |
MAX_DIGITS_IN_INT |
static String |
MIME_TYPE_AVRO_BINARY |
static Pattern |
NUMBER_PATTERN |
static Pattern |
SQL_TYPE_ATTRIBUTE_PATTERN |
| Constructor and Description |
|---|
JdbcCommon() |
| Modifier and Type | Method and Description |
|---|---|
private static void |
addNullableField(org.apache.avro.SchemaBuilder.FieldAssembler<org.apache.avro.Schema> builder,
String columnName,
Function<org.apache.avro.SchemaBuilder.BaseTypeBuilder<org.apache.avro.SchemaBuilder.UnionAccumulator<org.apache.avro.SchemaBuilder.NullDefault<org.apache.avro.Schema>>>,org.apache.avro.SchemaBuilder.UnionAccumulator<org.apache.avro.SchemaBuilder.NullDefault<org.apache.avro.Schema>>> func) |
static long |
convertToAvroStream(ResultSet rs,
OutputStream outStream,
boolean convertNames) |
static long |
convertToAvroStream(ResultSet rs,
OutputStream outStream,
JdbcCommon.AvroConversionOptions options,
JdbcCommon.ResultSetRowCallback callback) |
static long |
convertToAvroStream(ResultSet rs,
OutputStream outStream,
String recordName,
boolean convertNames) |
static long |
convertToAvroStream(ResultSet rs,
OutputStream outStream,
String recordName,
JdbcCommon.ResultSetRowCallback callback,
boolean convertNames) |
static long |
convertToAvroStream(ResultSet rs,
OutputStream outStream,
String recordName,
JdbcCommon.ResultSetRowCallback callback,
int maxRows,
boolean convertNames) |
static void |
createEmptyAvroStream(OutputStream outStream) |
static org.apache.avro.Schema |
createSchema(ResultSet rs) |
static org.apache.avro.Schema |
createSchema(ResultSet rs,
JdbcCommon.AvroConversionOptions options)
Creates an Avro schema from a result set.
|
static org.apache.avro.Schema |
createSchema(ResultSet rs,
String recordName,
boolean convertNames) |
static DateTimeFormatter |
getDateTimeFormatter(String pattern) |
static String |
normalizeNameForAvro(String inputName) |
static void |
setParameter(PreparedStatement stmt,
int parameterIndex,
String parameterValue,
int jdbcType,
String valueFormat)
Determines how to map the given value to the appropriate JDBC data type and sets the parameter on the
provided PreparedStatement
|
private static void |
setParameterAtIndex(PreparedStatement stmt,
Map<String,SensitiveValueWrapper> attributes,
String flowFileAttributeKey) |
static void |
setParameters(PreparedStatement stmt,
Map<String,String> attributes)
Sets all of the appropriate parameters on the given PreparedStatement, based on the given FlowFile attributes.
|
static void |
setSensitiveParameters(PreparedStatement stmt,
Map<String,SensitiveValueWrapper> attributes)
Sets all of the appropriate parameters on the given PreparedStatement, based on the given FlowFile attributes
and masks sensitive values.
|
public static final int MAX_DIGITS_IN_BIGINT
public static final int MAX_DIGITS_IN_INT
public static final int DEFAULT_PRECISION_VALUE
public static final int DEFAULT_SCALE_VALUE
public static final Pattern LONG_PATTERN
public static final Pattern SQL_TYPE_ATTRIBUTE_PATTERN
public static final Pattern NUMBER_PATTERN
public static final String MIME_TYPE_AVRO_BINARY
public static final String MASKED_LOG_VALUE
public static long convertToAvroStream(ResultSet rs, OutputStream outStream, boolean convertNames) throws SQLException, IOException
SQLExceptionIOExceptionpublic static long convertToAvroStream(ResultSet rs, OutputStream outStream, String recordName, boolean convertNames) throws SQLException, IOException
SQLExceptionIOExceptionpublic static long convertToAvroStream(ResultSet rs, OutputStream outStream, String recordName, JdbcCommon.ResultSetRowCallback callback, boolean convertNames) throws IOException, SQLException
IOExceptionSQLExceptionpublic static long convertToAvroStream(ResultSet rs, OutputStream outStream, String recordName, JdbcCommon.ResultSetRowCallback callback, int maxRows, boolean convertNames) throws SQLException, IOException
SQLExceptionIOExceptionpublic static void createEmptyAvroStream(OutputStream outStream) throws IOException
IOExceptionpublic static long convertToAvroStream(ResultSet rs, OutputStream outStream, JdbcCommon.AvroConversionOptions options, JdbcCommon.ResultSetRowCallback callback) throws SQLException, IOException
SQLExceptionIOExceptionpublic static org.apache.avro.Schema createSchema(ResultSet rs) throws SQLException
SQLExceptionpublic static org.apache.avro.Schema createSchema(ResultSet rs, String recordName, boolean convertNames) throws SQLException
SQLExceptionprivate static void addNullableField(org.apache.avro.SchemaBuilder.FieldAssembler<org.apache.avro.Schema> builder,
String columnName,
Function<org.apache.avro.SchemaBuilder.BaseTypeBuilder<org.apache.avro.SchemaBuilder.UnionAccumulator<org.apache.avro.SchemaBuilder.NullDefault<org.apache.avro.Schema>>>,org.apache.avro.SchemaBuilder.UnionAccumulator<org.apache.avro.SchemaBuilder.NullDefault<org.apache.avro.Schema>>> func)
public static org.apache.avro.Schema createSchema(ResultSet rs, JdbcCommon.AvroConversionOptions options) throws SQLException
rs - The result set to convert to Avrooptions - Specify various optionsSQLException - if any error occurs during conversionpublic static void setParameters(PreparedStatement stmt, Map<String,String> attributes) throws SQLException
stmt - the statement to set the parameters onattributes - the attributes from which to derive parameter indices, values, and typesSQLException - if the PreparedStatement throws a SQLException when the appropriate setter is calledpublic static void setSensitiveParameters(PreparedStatement stmt, Map<String,SensitiveValueWrapper> attributes) throws SQLException
stmt - the statement to set the parameters onattributes - the attributes from which to derive parameter indices, values, and typesSQLException - if the PreparedStatement throws a SQLException when the appropriate setter is calledprivate static void setParameterAtIndex(PreparedStatement stmt, Map<String,SensitiveValueWrapper> attributes, String flowFileAttributeKey) throws SQLException
SQLExceptionpublic static void setParameter(PreparedStatement stmt, int parameterIndex, String parameterValue, int jdbcType, String valueFormat) throws SQLException, ParseException, UnsupportedEncodingException
stmt - the PreparedStatement to set the parameter onparameterIndex - the index of the SQL parameter to setparameterValue - the value of the SQL parameter to setjdbcType - the JDBC Type of the SQL parameter to setSQLException - if the PreparedStatement throws a SQLException when calling the appropriate setterParseExceptionUnsupportedEncodingExceptionpublic static DateTimeFormatter getDateTimeFormatter(String pattern)
Copyright © 2023 Apache NiFi Project. All rights reserved.