java.lang.Object
org.tentackle.sql.DefaultScriptRunner
- All Implemented Interfaces:
ScriptRunner
- Direct Known Subclasses:
PostgresScriptRunner
Default implementation of a script runner.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordThe next SQL code to execute as a statement. -
Constructor Summary
ConstructorsConstructorDescriptionDefaultScriptRunner(Backend backend, Connection connection) Creates a script runner. -
Method Summary
Modifier and TypeMethodDescriptiondetermineNextSqlCode(String script, int offset) Determines the next SQL code to execute.protected booleanDetermines whether Posix escape syntax is supported by the backend and/or connection.Gets the backend for this script runner.Gets the connection for this script runner.booleanReturns whether JDBC escape processing is enabled.Runs the SQL script.voidsetEscapeProcessingEnabled(boolean enabled) Enables or disables JDBC escape processing.
-
Constructor Details
-
DefaultScriptRunner
Creates a script runner.- Parameters:
backend- the backendconnection- the SQL connection- See Also:
-
-
Method Details
-
getBackend
Description copied from interface:ScriptRunnerGets the backend for this script runner.- Specified by:
getBackendin interfaceScriptRunner- Returns:
- the backend
-
getConnection
Description copied from interface:ScriptRunnerGets the connection for this script runner.- Specified by:
getConnectionin interfaceScriptRunner- Returns:
- the connection
-
setEscapeProcessingEnabled
public void setEscapeProcessingEnabled(boolean enabled) Description copied from interface:ScriptRunnerEnables or disables JDBC escape processing.- Specified by:
setEscapeProcessingEnabledin interfaceScriptRunner- Parameters:
enabled- true if escape processing is enabled- See Also:
-
isEscapeProcessingEnabled
public boolean isEscapeProcessingEnabled()Description copied from interface:ScriptRunnerReturns whether JDBC escape processing is enabled.- Specified by:
isEscapeProcessingEnabledin interfaceScriptRunner- Returns:
- true if enabled (default)
-
run
Description copied from interface:ScriptRunnerRuns the SQL script.Throws
BackendExceptionif script execution failed.- Specified by:
runin interfaceScriptRunner- Parameters:
script- the SQL script- Returns:
- the results, never null
-
determineNextSqlCode
Determines the next SQL code to execute.- Parameters:
script- the SQL scriptoffset- the offset where to start in the script to find the next statement- Returns:
- the next SQL code to send to the database, null if end of script found
-
determinePosixEscapeSyntaxSupported
protected boolean determinePosixEscapeSyntaxSupported()Determines whether Posix escape syntax is supported by the backend and/or connection.- Returns:
- true if supported
-