org.dellroad.stuff.schema
Class SQLCommand
java.lang.Object
org.dellroad.stuff.schema.SQLCommand
- All Implemented Interfaces:
- DatabaseAction<Connection>
public class SQLCommand
- extends Object
- implements DatabaseAction<Connection>
An SQL DatabaseAction that executes a single SQL statement.
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
log
protected final Logger log
SQLCommand
public SQLCommand(String sql)
- Constructor.
- Parameters:
sql - the SQL to execute; must be a single statement
- Throws:
IllegalArgumentException - if sql is null or contains only whitespace
getSQL
public String getSQL()
apply
public void apply(Connection c)
throws SQLException
- Execute the SQL statement.
The implementation in SQLCommand creates a Statement and then executes the configured
SQL command via Statement.execute(java.lang.String). Subclasses may wish to override.
- Specified by:
apply in interface DatabaseAction<Connection>
- Parameters:
c - open transaction
- Throws:
SQLException - if an error occurs while accessing the database