public class SqlScriptRunner extends Object
| Modifier and Type | Field and Description |
|---|---|
static Pattern |
delimP
regex to detect delimiter.
|
| Constructor and Description |
|---|
SqlScriptRunner()
Default constructor
|
| Modifier and Type | Method and Description |
|---|---|
static QueryResult |
execCommand(Connection conn,
String command) |
static QueryResult |
execCommand(Connection conn,
String command,
boolean instrumented) |
static InsertionResultsDto |
execInsert(Connection conn,
List<InsertionDto> insertions,
InsertionResultsDto... previous)
Execute the different SQL insertions.
|
static Long |
execInsert(Connection conn,
String command) |
static void |
execScript(Connection conn,
String script)
this is used for mysql which cannot execute multiple statements at one time.
|
List<String> |
readCommands(Reader reader) |
static void |
runCommands(Connection connection,
List<String> commands) |
static void |
runScript(Connection connection,
Reader reader)
Runs an SQL script (read in using the Reader parameter)
|
static void |
runScriptFromResourceFile(Connection connection,
String resourcePath) |
void |
setDelimiter(String delimiter,
boolean fullLineDelimiter) |
public static final Pattern delimP
public void setDelimiter(String delimiter, boolean fullLineDelimiter)
public static void runScript(Connection connection, Reader reader)
reader - - the source of the scriptpublic static void runScriptFromResourceFile(Connection connection, String resourcePath)
public static void runCommands(Connection connection, List<String> commands)
public static InsertionResultsDto execInsert(Connection conn, List<InsertionDto> insertions, InsertionResultsDto... previous) throws SQLException
conn - a JDBC connection to the databaseinsertions - the SQL insertions to executeprevious - the results of previously executed SQL insertionsSQLExceptionpublic static Long execInsert(Connection conn, String command) throws SQLException
conn - a JDBC connection to the databasecommand - the SQL insertion to executenull otherwise.
In other words, return the value of auto-generated primary key, if any was created.SQLExceptionpublic static void execScript(Connection conn, String script) throws SQLException
conn - a connection to dbscript - represents a sql scriptSQLException - if the execution of the command failspublic static QueryResult execCommand(Connection conn, String command) throws SQLException
SQLExceptionpublic static QueryResult execCommand(Connection conn, String command, boolean instrumented) throws SQLException
SQLExceptionCopyright © 2016–2021. All rights reserved.