|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectfedora.server.utilities.SQLUtility
public abstract class SQLUtility
SQL-related utility methods.
Implementation note: Many of these static methods use JDBC objects
which are difficult to mock out for unit tests. The methods now delegate to
an instance of SQLUtilityImpl instead. The instance is declared
private, but not final, so it can be
overridden for unit tests. For example, see
TestFieldSearchSQLImpl.java.
Some of the methods involve no JDBC objects, and so are not delegated to the instance.
| Constructor Summary | |
|---|---|
SQLUtility()
|
|
| Method Summary | |
|---|---|
static void |
addRow(java.sql.Connection conn,
java.lang.String table,
java.lang.String[] columns,
java.lang.String[] values,
boolean[] numeric)
Adds a new row. |
static java.lang.String |
aposEscape(java.lang.String in)
|
static java.lang.String |
backslashEscape(java.lang.String in)
|
static void |
createNonExistingTables(ConnectionPool cPool,
java.io.InputStream dbSpec)
|
static ConnectionPool |
getConnectionPool(DatastoreConfiguration cpDC)
|
static ConnectionPool |
getConnectionPool(ServerConfiguration fcfg)
|
static java.lang.String |
getLongString(java.sql.ResultSet rs,
int pos)
Get a long string, which could be a TEXT or CLOB type. |
protected abstract void |
i_addRow(java.sql.Connection conn,
java.lang.String table,
java.lang.String[] columns,
java.lang.String[] values,
boolean[] numeric)
|
protected abstract void |
i_createNonExistingTables(ConnectionPool pool,
java.io.InputStream dbSpec)
|
protected abstract void |
i_createTables(TableCreatingConnection tcConn,
java.util.List<TableSpec> specs)
|
protected abstract ConnectionPool |
i_getConnectionPool(DatastoreConfiguration cpDC)
|
protected abstract java.lang.String |
i_getLongString(java.sql.ResultSet rs,
int pos)
|
protected abstract java.util.List<TableSpec> |
i_getNonExistingTables(java.sql.Connection conn,
java.util.List<TableSpec> specs)
|
protected abstract void |
i_replaceInto(java.sql.Connection conn,
java.lang.String table,
java.lang.String[] columns,
java.lang.String[] values,
java.lang.String uniqueColumn,
boolean[] numeric)
|
protected abstract boolean |
i_updateRow(java.sql.Connection conn,
java.lang.String table,
java.lang.String[] columns,
java.lang.String[] values,
java.lang.String uniqueColumn,
boolean[] numeric)
|
static void |
replaceInto(java.sql.Connection conn,
java.lang.String tableName,
java.lang.String[] columns,
java.lang.String[] values,
java.lang.String uniqueColumn)
|
static void |
replaceInto(java.sql.Connection conn,
java.lang.String table,
java.lang.String[] columns,
java.lang.String[] values,
java.lang.String uniqueColumn,
boolean[] numeric)
Adds or replaces a row in the given table. |
static java.lang.String |
slashEscaped(java.lang.String in)
|
static boolean |
updateRow(java.sql.Connection conn,
java.lang.String table,
java.lang.String[] columns,
java.lang.String[] values,
java.lang.String uniqueColumn,
boolean[] numeric)
Updates an existing row. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public SQLUtility()
| Method Detail |
|---|
public static ConnectionPool getConnectionPool(ServerConfiguration fcfg)
throws java.sql.SQLException
java.sql.SQLException
public static ConnectionPool getConnectionPool(DatastoreConfiguration cpDC)
throws java.sql.SQLException
java.sql.SQLException
public static void replaceInto(java.sql.Connection conn,
java.lang.String tableName,
java.lang.String[] columns,
java.lang.String[] values,
java.lang.String uniqueColumn)
throws java.sql.SQLException
java.sql.SQLException
public static void replaceInto(java.sql.Connection conn,
java.lang.String table,
java.lang.String[] columns,
java.lang.String[] values,
java.lang.String uniqueColumn,
boolean[] numeric)
throws java.sql.SQLException
conn - the connection to usetable - the name of the tablecolumns - the names of the columns whose values we're setting.values - associated valuesuniqueColumn - which column name is unique? The value of this column will be used
in the where clause. It must be a column which is not numeric.numeric - for each associated column, is it numeric? if null, all columns
are assumed to be strings.
java.sql.SQLException
public static boolean updateRow(java.sql.Connection conn,
java.lang.String table,
java.lang.String[] columns,
java.lang.String[] values,
java.lang.String uniqueColumn,
boolean[] numeric)
throws java.sql.SQLException
java.sql.SQLException
public static void addRow(java.sql.Connection conn,
java.lang.String table,
java.lang.String[] columns,
java.lang.String[] values,
boolean[] numeric)
throws java.sql.SQLException
java.sql.SQLException - if the row could not be added.
public static java.lang.String getLongString(java.sql.ResultSet rs,
int pos)
throws java.sql.SQLException
java.sql.SQLException
public static void createNonExistingTables(ConnectionPool cPool,
java.io.InputStream dbSpec)
throws java.io.IOException,
InconsistentTableSpecException,
java.sql.SQLException
java.io.IOException
InconsistentTableSpecException
java.sql.SQLExceptionpublic static java.lang.String slashEscaped(java.lang.String in)
public static java.lang.String backslashEscape(java.lang.String in)
public static java.lang.String aposEscape(java.lang.String in)
protected abstract ConnectionPool i_getConnectionPool(DatastoreConfiguration cpDC)
throws java.sql.SQLException
java.sql.SQLException
protected abstract void i_replaceInto(java.sql.Connection conn,
java.lang.String table,
java.lang.String[] columns,
java.lang.String[] values,
java.lang.String uniqueColumn,
boolean[] numeric)
throws java.sql.SQLException
java.sql.SQLException
protected abstract boolean i_updateRow(java.sql.Connection conn,
java.lang.String table,
java.lang.String[] columns,
java.lang.String[] values,
java.lang.String uniqueColumn,
boolean[] numeric)
throws java.sql.SQLException
java.sql.SQLException
protected abstract void i_addRow(java.sql.Connection conn,
java.lang.String table,
java.lang.String[] columns,
java.lang.String[] values,
boolean[] numeric)
throws java.sql.SQLException
java.sql.SQLException
protected abstract void i_createNonExistingTables(ConnectionPool pool,
java.io.InputStream dbSpec)
throws java.io.IOException,
InconsistentTableSpecException,
java.sql.SQLException
java.io.IOException
InconsistentTableSpecException
java.sql.SQLException
protected abstract java.util.List<TableSpec> i_getNonExistingTables(java.sql.Connection conn,
java.util.List<TableSpec> specs)
throws java.sql.SQLException
java.sql.SQLException
protected abstract void i_createTables(TableCreatingConnection tcConn,
java.util.List<TableSpec> specs)
throws java.sql.SQLException
java.sql.SQLException
protected abstract java.lang.String i_getLongString(java.sql.ResultSet rs,
int pos)
throws java.sql.SQLException
java.sql.SQLException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||