Class ScriptExecutorTool
- java.lang.Object
-
- de.akquinet.jbosscc.guttenbase.tools.ScriptExecutorTool
-
public class ScriptExecutorTool extends Object
Execute given SQL script or single statements separated by given delimiter. Delimiter is ';' by default.- Author:
- M. Dahm
© 2012-2034 akquinet tech@spree
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
ScriptExecutorTool.Command
static class
ScriptExecutorTool.StatementCommand
-
Field Summary
Fields Modifier and Type Field Description static String
DEFAULT_ENCODING
-
Constructor Summary
Constructors Constructor Description ScriptExecutorTool(ConnectorRepository connectorRepository)
ScriptExecutorTool(ConnectorRepository connectorRepository, char delimiter)
ScriptExecutorTool(ConnectorRepository connectorRepository, char delimiter, String encoding)
ScriptExecutorTool(ConnectorRepository connectorRepository, String encoding)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
executeFileScript(String connectorId, boolean updateSchema, boolean prepareTargetConnection, String resourceName)
Read SQL from file somewhere on class path.void
executeFileScript(String connectorId, String resourceName)
Read SQL from file somewhere on class path.List<Map<String,Object>>
executeQuery(String connectorId, String sql)
Execute query (i.e.void
executeQuery(String connectorId, String sql, ScriptExecutorTool.Command action)
Execute query (i.e.List<Map<String,Object>>
executeQuery(Connection connection, String sql)
Execute query (i.e.void
executeQuery(Connection connection, String sql, ScriptExecutorTool.Command action)
Execute query (i.e.void
executeScript(String connectorId, boolean updateSchema, boolean prepareTargetConnection, String... lines)
Execute given lines of SQL.void
executeScript(String connectorId, boolean scriptUpdatesSchema, boolean prepareTargetConnection, List<String> lines)
Execute given lines of SQL.void
executeScript(String connectorId, String... lines)
Execute given lines of SQL.void
executeScript(String connectorId, List<String> lines)
Execute given lines of SQL.
-
-
-
Field Detail
-
DEFAULT_ENCODING
public static final String DEFAULT_ENCODING
-
-
Constructor Detail
-
ScriptExecutorTool
public ScriptExecutorTool(ConnectorRepository connectorRepository, char delimiter, String encoding)
-
ScriptExecutorTool
public ScriptExecutorTool(ConnectorRepository connectorRepository, String encoding)
-
ScriptExecutorTool
public ScriptExecutorTool(ConnectorRepository connectorRepository, char delimiter)
-
ScriptExecutorTool
public ScriptExecutorTool(ConnectorRepository connectorRepository)
-
-
Method Detail
-
executeFileScript
public void executeFileScript(String connectorId, String resourceName) throws SQLException
Read SQL from file somewhere on class path. Each statement (not line!) must end with a ';'- Throws:
SQLException
-
executeFileScript
public void executeFileScript(String connectorId, boolean updateSchema, boolean prepareTargetConnection, String resourceName) throws SQLException
Read SQL from file somewhere on class path. Each statement (not line!) must end with a ';'- Throws:
SQLException
-
executeScript
public void executeScript(String connectorId, String... lines) throws SQLException
Execute given lines of SQL. Each statement (not line!) must end with a ';'- Throws:
SQLException
-
executeScript
public void executeScript(String connectorId, boolean updateSchema, boolean prepareTargetConnection, String... lines) throws SQLException
Execute given lines of SQL. Each statement (not line!) must end with a ';'- Throws:
SQLException
-
executeScript
public void executeScript(String connectorId, List<String> lines) throws SQLException
Execute given lines of SQL. Each statement (not line!) must with a ';'- Throws:
SQLException
-
executeScript
public void executeScript(String connectorId, boolean scriptUpdatesSchema, boolean prepareTargetConnection, List<String> lines) throws SQLException
Execute given lines of SQL. Each statement (not line!) must end with a ';'- Parameters:
connectorId
-scriptUpdatesSchema
- The script alters the schema, scheme information needs to be reloadedprepareTargetConnection
- the target connection is initialized using the appropriateTargetDatabaseConfiguration
lines
- SQL statements ending with ';'- Throws:
SQLException
-
executeQuery
public List<Map<String,Object>> executeQuery(String connectorId, String sql) throws SQLException
Execute query (i.e. SELECT...) and return the result set as a list of Maps where the key is the column name and the value the respective data.- Throws:
SQLException
-
executeQuery
public void executeQuery(String connectorId, String sql, ScriptExecutorTool.Command action) throws SQLException
Execute query (i.e. SELECT...) and execute the given command on each row of data- Throws:
SQLException
-
executeQuery
public List<Map<String,Object>> executeQuery(Connection connection, String sql) throws SQLException
Execute query (i.e. SELECT...) and return the result set as a list of Maps where the key is the upper case column name and the value is the respective data of the column.- Throws:
SQLException
-
executeQuery
public void executeQuery(Connection connection, String sql, ScriptExecutorTool.Command action) throws SQLException
Execute query (i.e. SELECT...) and execute the given command on each row of data- Throws:
SQLException
-
-