public class DatabaseConnection
extends java.lang.Object
| Constructor and Description |
|---|
DatabaseConnection(DatabaseConnectionConfig config) |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
void |
connect() |
java.sql.Statement |
createReadOnlyStatement() |
DatabaseConnectionConfig |
getConfig() |
java.sql.Connection |
getConnection() |
void |
insertOrUpdate(DatabaseConnection connection,
java.lang.String table,
java.lang.String keyField1,
java.lang.String keyField2,
Naming values)
Same as the other insertOrUpdate, but with two key values instead of one.
|
void |
insertOrUpdate(java.lang.String table,
java.lang.String keyField,
Naming values)
A convenience method that updates a single table using the given values
and key field.
|
java.util.ArrayList |
listCatalogs() |
java.util.ArrayList |
listColumns(java.lang.String tableName) |
java.util.ArrayList |
listSchemas() |
Naming |
listTableOwners() |
java.util.ArrayList |
listTables() |
java.util.ArrayList |
oneColumnQuery(java.lang.String query)
Runs the given query and returns the result, which is assumed to be a
single column, as an ArrayList.
|
java.lang.String |
oneFieldQuery(java.lang.String query)
Runs the given query and returns the result, which is assumed to be a
single value (1 row, 1 column).
|
Naming |
oneRowQuery(java.lang.String query)
Runs the given query and returns the result, which is assumed to be a
single row, as a Naming.
|
java.sql.PreparedStatement |
prepareStatement(java.lang.String query) |
void |
runScript(java.lang.String query)
Runs some kind of update query; doesn't return anything.
|
public DatabaseConnection(DatabaseConnectionConfig config)
public void connect()
throws java.sql.SQLException
java.sql.SQLExceptionpublic DatabaseConnectionConfig getConfig()
public java.sql.Connection getConnection()
public java.sql.Statement createReadOnlyStatement()
throws java.sql.SQLException
java.sql.SQLExceptionpublic void close()
throws java.sql.SQLException
java.sql.SQLExceptionpublic java.sql.PreparedStatement prepareStatement(java.lang.String query)
throws java.sql.SQLException
java.sql.SQLExceptionpublic java.lang.String oneFieldQuery(java.lang.String query)
throws java.sql.SQLException
java.sql.SQLExceptionpublic Naming oneRowQuery(java.lang.String query) throws java.sql.SQLException
java.sql.SQLExceptionpublic java.util.ArrayList oneColumnQuery(java.lang.String query)
throws java.sql.SQLException
java.sql.SQLExceptionpublic void runScript(java.lang.String query)
throws java.sql.SQLException
java.sql.SQLExceptionpublic java.util.ArrayList listTables()
throws java.sql.SQLException
java.sql.SQLExceptionpublic Naming listTableOwners() throws java.sql.SQLException
java.sql.SQLExceptionpublic java.util.ArrayList listCatalogs()
throws java.sql.SQLException
java.sql.SQLExceptionpublic java.util.ArrayList listSchemas()
throws java.sql.SQLException
java.sql.SQLExceptionpublic java.util.ArrayList listColumns(java.lang.String tableName)
throws java.sql.SQLException
java.sql.SQLExceptionpublic void insertOrUpdate(java.lang.String table,
java.lang.String keyField,
Naming values)
throws java.sql.SQLException
java.sql.SQLExceptionpublic void insertOrUpdate(DatabaseConnection connection, java.lang.String table, java.lang.String keyField1, java.lang.String keyField2, Naming values) throws java.sql.SQLException
connection - table - keyField1 - keyField2 - values - java.sql.SQLException