public class JDBCOutputFormat extends RichOutputFormat<Row>
Row
,
DriverManager
,
Serialized FormModifier and Type | Class and Description |
---|---|
static class |
JDBCOutputFormat.JDBCOutputFormatBuilder
Builder for a
JDBCOutputFormat . |
Constructor and Description |
---|
JDBCOutputFormat() |
Modifier and Type | Method and Description |
---|---|
static JDBCOutputFormat.JDBCOutputFormatBuilder |
buildJDBCOutputFormat() |
void |
close()
Executes prepared statement and closes all resources of this instance.
|
void |
configure(Configuration parameters)
Configures this output format.
|
void |
open(int taskNumber,
int numTasks)
Connects to the target database and initializes the prepared statement.
|
void |
writeRecord(Row row)
Adds a record to the prepared statement.
|
getRuntimeContext, setRuntimeContext
public void configure(Configuration parameters)
OutputFormat
This method is always called first on a newly instantiated output format.
parameters
- The configuration with all parameters.public void open(int taskNumber, int numTasks) throws IOException
taskNumber
- The number of the parallel instance.numTasks
- The number of parallel tasks.IOException
- Thrown, if the output could not be opened due to an
I/O problem.public void writeRecord(Row row) throws IOException
When this method is called, the output format is guaranteed to be opened.
WARNING: this may fail when no column types specified (because a best effort approach is attempted in order to insert a null value but it's not guaranteed that the JDBC driver handles PreparedStatement.setObject(pos, null))
row
- The records to add to the output.IOException
- Thrown, if the records could not be added due to an I/O problem.PreparedStatement
public void close() throws IOException
IOException
- Thrown, if the input could not be closed properly.public static JDBCOutputFormat.JDBCOutputFormatBuilder buildJDBCOutputFormat()
Copyright © 2014–2019 The Apache Software Foundation. All rights reserved.