public class SQLUpdate extends Object implements AutoCloseable
ConnectionPoolManager class to assist
with the creation of a connection to the database, which in turn requires
the appropriate dbpool.properties file in the classpath.
Usage: java snaq.db.SQLUpdate <poolnames> <input file> [<separator>]
where pool is the name of the connection pool as defined in
the dbpool.properties file, input file is the name of the text
file containing the SQL statements to be issued to the defined database,
and separator is an optional parameter to specify a delimiter
for the SQL statements in the file. If the separator is not specified then
each line of the file is assumed to be a separate statement.
Note: comments are allowed in the input file by starting the line with either "#" or "--".
ConnectionPoolManager| Modifier and Type | Field and Description |
|---|---|
protected static org.slf4j.Logger |
logger
SLF4J shared instance for writing log entries.
|
| Constructor and Description |
|---|
SQLUpdate(Connection con) |
SQLUpdate(String poolname) |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the current database connection.
|
void |
doStatement(String sql)
Issues a statement to the database.
|
static String |
loadTextFile(File f)
Loads a text file into a string.
|
static void |
main(String[] args) |
static String[] |
splitSQL(String text,
String separator)
Splits the specified text input into separate SQL statements.
|
protected static final org.slf4j.Logger logger
public SQLUpdate(String poolname) throws IOException, SQLException
IOExceptionSQLExceptionpublic SQLUpdate(Connection con) throws SQLException
SQLExceptionpublic void close()
close in interface AutoCloseablepublic void doStatement(String sql) throws SQLException
sql - SQL command to issueSQLExceptionpublic static final String loadTextFile(File f) throws IOException
f - File containing text to loadString containing the text loaded from the specified fileIOExceptionpublic static String[] splitSQL(String text, String separator)
text - string containing the text to be processedseparator - string specifying the separator between SQL statementsString array containing the SQL statements parsedCopyright © 2013. All Rights Reserved.