Modifier and Type | Class | Description |
---|---|---|
static class |
JdbcWriter.Value |
Values to insert into database.
|
Constructor | Description |
---|---|
JdbcWriter(String url,
String table,
List<String> columns,
List<JdbcWriter.Value> values) |
|
JdbcWriter(String url,
String table,
List<String> columns,
List<JdbcWriter.Value> values,
boolean batch) |
|
JdbcWriter(String url,
String table,
List<String> columns,
List<JdbcWriter.Value> values,
boolean batch,
int reconnect) |
|
JdbcWriter(String url,
String table,
List<String> columns,
List<JdbcWriter.Value> values,
boolean batch,
String username,
String password) |
|
JdbcWriter(String url,
String table,
List<String> columns,
List<JdbcWriter.Value> values,
boolean batch,
String username,
String password,
int reconnect) |
|
JdbcWriter(String url,
String table,
List<String> columns,
List<JdbcWriter.Value> values,
String username,
String password) |
|
JdbcWriter(String url,
String table,
List<JdbcWriter.Value> values) |
|
JdbcWriter(String url,
String table,
List<JdbcWriter.Value> values,
boolean batch) |
|
JdbcWriter(String url,
String table,
List<JdbcWriter.Value> values,
boolean batch,
int reconnect) |
|
JdbcWriter(String url,
String table,
List<JdbcWriter.Value> values,
boolean batch,
String username,
String password) |
|
JdbcWriter(String url,
String table,
List<JdbcWriter.Value> values,
boolean batch,
String username,
String password,
int reconnect) |
|
JdbcWriter(String url,
String table,
List<JdbcWriter.Value> values,
String username,
String password) |
Modifier and Type | Method | Description |
---|---|---|
void |
close() |
Close the writer and release all resources.
|
void |
flush() |
Flush this writer and force any buffered data to output.
|
List<String> |
getColumns() |
Get the columns of the table, which are used for the insert statement.
|
String |
getPassword() |
Get the password for database log in.
|
long |
getReconnetInterval() |
Get the minimum time span in milliseconds between two reconnecting tries to database if connecting is broken.
|
Set<LogEntryValue> |
getRequiredLogEntryValues() |
Get all log entry values that are required by this writer.
|
String |
getTable() |
Get the name of the database table.
|
String |
getUrl() |
Get the JDBC connection URL to database.
|
String |
getUsername() |
Get the user name for database log in.
|
List<JdbcWriter.Value> |
getValues() |
Get all values to insert.
|
void |
init(Configuration configuration) |
Initialize the writer (open a file for example).
|
boolean |
isBatchMode() |
Determine whether batch mode is enabled.
|
void |
write(LogEntry logEntry) |
Write a log entry.
|
public JdbcWriter(String url, String table, List<JdbcWriter.Value> values)
url
- JDBC connection URLtable
- Name of tablevalues
- Values to insertpublic JdbcWriter(String url, String table, List<JdbcWriter.Value> values, boolean batch)
url
- JDBC connection URLtable
- Name of tablevalues
- Values to insertbatch
- true
for collecting SQL statements and execute them in a batch process,
false
to execute SQL statements immediately (default)public JdbcWriter(String url, String table, List<JdbcWriter.Value> values, boolean batch, int reconnect)
url
- JDBC connection URLtable
- Name of tablevalues
- Values to insertbatch
- true
for collecting SQL statements and execute them in a batch process,
false
to execute SQL statements immediately (default)reconnect
- Seconds between two reconnecting tries to database if connecting is broken (-1 disables reconnecting)public JdbcWriter(String url, String table, List<JdbcWriter.Value> values, String username, String password)
url
- JDBC connection URLtable
- Name of tablevalues
- Values to insertusername
- User name for database log inpassword
- Password for database log inpublic JdbcWriter(String url, String table, List<JdbcWriter.Value> values, boolean batch, String username, String password)
url
- JDBC connection URLtable
- Name of tablevalues
- Values to insertbatch
- true
for collecting SQL statements and execute them in a batch process,
false
to execute SQL statements immediately (default)username
- User name for database log inpassword
- Password for database log inpublic JdbcWriter(String url, String table, List<JdbcWriter.Value> values, boolean batch, String username, String password, int reconnect)
url
- JDBC connection URLtable
- Name of tablevalues
- Values to insertbatch
- true
for collecting SQL statements and execute them in a batch process,
false
to execute SQL statements immediately (default)username
- User name for database log inpassword
- Password for database log inreconnect
- Seconds between two reconnecting tries to database if connecting is broken (-1 disables reconnecting)public JdbcWriter(String url, String table, List<String> columns, List<JdbcWriter.Value> values)
url
- JDBC connection URLtable
- Name of tablecolumns
- Columns of table to use for insertvalues
- Values to insertpublic JdbcWriter(String url, String table, List<String> columns, List<JdbcWriter.Value> values, boolean batch)
url
- JDBC connection URLtable
- Name of tablecolumns
- Columns of table to use for insertvalues
- Values to insertbatch
- true
for collecting SQL statements and execute them in a batch process,
false
to execute SQL statements immediately (default)public JdbcWriter(String url, String table, List<String> columns, List<JdbcWriter.Value> values, boolean batch, int reconnect)
url
- JDBC connection URLtable
- Name of tablecolumns
- Columns of table to use for insertvalues
- Values to insertbatch
- true
for collecting SQL statements and execute them in a batch process,
false
to execute SQL statements immediately (default)reconnect
- Seconds two between reconnecting tries to database if connecting is broken (-1 disables reconnecting)public JdbcWriter(String url, String table, List<String> columns, List<JdbcWriter.Value> values, String username, String password)
url
- JDBC connection URLtable
- Name of tablecolumns
- Columns of table to use for insertvalues
- Values to insertusername
- User name for database log inpassword
- Password for database log inpublic JdbcWriter(String url, String table, List<String> columns, List<JdbcWriter.Value> values, boolean batch, String username, String password)
url
- JDBC connection URLtable
- Name of tablecolumns
- Columns of table to use for insertvalues
- Values to insertbatch
- true
for collecting SQL statements and execute them in a batch process,
false
to execute SQL statements immediately (default)username
- User name for database log inpassword
- Password for database log inpublic JdbcWriter(String url, String table, List<String> columns, List<JdbcWriter.Value> values, boolean batch, String username, String password, int reconnect)
url
- JDBC connection URLtable
- Name of tablecolumns
- Columns of table to use for insertvalues
- Values to insertbatch
- true
for collecting SQL statements and execute them in a batch process,
false
to execute SQL statements immediately (default)username
- User name for database log inpassword
- Password for database log inreconnect
- Seconds between two reconnecting tries to database if connecting is broken (-1 disables reconnecting)public String getUrl()
public String getTable()
public List<String> getColumns()
public List<JdbcWriter.Value> getValues()
public boolean isBatchMode()
true
if batch mode is enabled, false
if notpublic String getUsername()
public String getPassword()
public long getReconnetInterval()
public Set<LogEntryValue> getRequiredLogEntryValues()
Writer
getRequiredLogEntryValues
in interface Writer
public void init(Configuration configuration) throws SQLException, NamingException
Writer
init
in interface Writer
configuration
- Configuration of loggerSQLException
NamingException
public void write(LogEntry logEntry) throws SQLException
Writer
write
in interface Writer
logEntry
- Log entry to outputSQLException
public void flush() throws SQLException
Writer
flush
in interface Writer
SQLException
public void close() throws SQLException
Writer
close()
call, it should be
registered in the init()
method at VMShutdownHook
for
automatically shutdown when VM will be shutdown.close
in interface Writer
SQLException
Copyright © 2019. All rights reserved.