public interface JDBCResourceManager
extends org.apache.beam.it.common.ResourceManager
Modifier and Type | Interface and Description |
---|---|
static class |
JDBCResourceManager.JDBCSchema
Object for managing JDBC table schemas in
JDBCResourceManager instances. |
Modifier and Type | Method and Description |
---|---|
boolean |
createTable(java.lang.String tableName,
JDBCResourceManager.JDBCSchema schema)
Creates a table within the current database given a table name and JDBC schema.
|
java.lang.String |
getDatabaseName()
Returns the name of the Database that this JDBC manager will operate in.
|
java.lang.String |
getPassword()
Returns the password used to log in to the JDBC database.
|
long |
getRowCount(java.lang.String tableName)
Gets the number of rows in table.
|
java.util.List<java.lang.String> |
getTableSchema(java.lang.String tableName)
Returns the schema of the given table as a list of strings.
|
java.lang.String |
getUri()
Returns the URI connection string to the JDBC Database.
|
java.lang.String |
getUsername()
Returns the username used to log in to the JDBC database.
|
java.util.List<java.util.Map<java.lang.String,java.lang.Object>> |
readTable(java.lang.String tableName)
Reads all the rows in a table and returns in the format of a list of Maps, which contain all
the columns (including ID).
|
java.util.List<java.util.Map<java.lang.String,java.lang.Object>> |
runSQLQuery(java.lang.String sql)
Run the given SQL query.
|
void |
runSQLUpdate(java.lang.String sql)
Run the given SQL DML statement (INSERT, UPDATE and DELETE).
|
boolean |
write(java.lang.String tableName,
java.util.List<java.util.Map<java.lang.String,java.lang.Object>> rows)
Writes the given mapped rows into the specified columns.
|
java.lang.String getUri()
java.lang.String getUsername()
java.lang.String getPassword()
java.lang.String getDatabaseName()
boolean createTable(java.lang.String tableName, JDBCResourceManager.JDBCSchema schema) throws JDBCResourceManagerException
tableName
- The name of the table.schema
- A JDBCResourceManager.JDBCSchema
object that defines the table.JDBCResourceManagerException
- if there is an error creating the table or if the table
already exists.boolean write(java.lang.String tableName, java.util.List<java.util.Map<java.lang.String,java.lang.Object>> rows) throws JDBCResourceManagerException
createTable(String, JDBCSchema)
to be called for the target table
beforehand.
The maps in the rows list must use the column name as the key. i.e. [{col1: val1, col2: val2, ...}, {col1: val3, col2: val4, ...}, ...]
tableName
- The name of the table to insert the given rows into.rows
- A list of maps representing the rows to be inserted into the table.JDBCResourceManagerException
- if method is called after resources have been cleaned up,
if the manager object has no dataset, if the table does not exist or if there is an
Exception when attempting to insert the rows.java.util.List<java.util.Map<java.lang.String,java.lang.Object>> readTable(java.lang.String tableName)
tableName
- The name of the table to read rows from.java.util.List<java.lang.String> getTableSchema(java.lang.String tableName)
tableName
- the name of the table to fetch the schema of.java.util.List<java.util.Map<java.lang.String,java.lang.Object>> runSQLQuery(java.lang.String sql)
sql
- The SQL query to run.void runSQLUpdate(java.lang.String sql)
sql
- The SQL DML statement to run.long getRowCount(java.lang.String tableName)
tableName
- The name of the table.