|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.fcrepo.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(Connection conn,
String table,
String[] columns,
String[] values,
boolean[] numeric)
Adds a new row. |
static void |
createNonExistingTables(ConnectionPool cPool,
InputStream dbSpec)
|
static ConnectionPool |
getConnectionPool(DatastoreConfiguration cpDC)
|
static ConnectionPool |
getConnectionPool(ServerConfiguration fcfg)
|
static String |
getLongString(ResultSet rs,
int pos)
Get a long string, which could be a TEXT or CLOB type. |
protected abstract void |
i_addRow(Connection conn,
String table,
String[] columns,
String[] values,
boolean[] numeric)
|
protected abstract void |
i_createNonExistingTables(ConnectionPool pool,
InputStream dbSpec)
|
protected abstract void |
i_createTables(TableCreatingConnection tcConn,
List<TableSpec> specs)
|
protected abstract ConnectionPool |
i_getConnectionPool(DatastoreConfiguration cpDC)
|
protected abstract String |
i_getLongString(ResultSet rs,
int pos)
|
protected abstract List<TableSpec> |
i_getNonExistingTables(Connection conn,
List<TableSpec> specs)
|
protected abstract void |
i_replaceInto(Connection conn,
String table,
String[] columns,
String[] values,
String uniqueColumn,
boolean[] numeric)
|
protected abstract boolean |
i_updateRow(Connection conn,
String table,
String[] columns,
String[] values,
String uniqueColumn,
boolean[] numeric)
|
static void |
replaceInto(Connection conn,
String tableName,
String[] columns,
String[] values,
String uniqueColumn)
|
static void |
replaceInto(Connection conn,
String table,
String[] columns,
String[] values,
String uniqueColumn,
boolean[] numeric)
Adds or replaces a row in the given table. |
static boolean |
updateRow(Connection conn,
String table,
String[] columns,
String[] values,
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 SQLException
SQLException
public static ConnectionPool getConnectionPool(DatastoreConfiguration cpDC)
throws SQLException
SQLException
public static void replaceInto(Connection conn,
String tableName,
String[] columns,
String[] values,
String uniqueColumn)
throws SQLException
SQLException
public static void replaceInto(Connection conn,
String table,
String[] columns,
String[] values,
String uniqueColumn,
boolean[] numeric)
throws 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.
SQLException
public static boolean updateRow(Connection conn,
String table,
String[] columns,
String[] values,
String uniqueColumn,
boolean[] numeric)
throws SQLException
SQLException
public static void addRow(Connection conn,
String table,
String[] columns,
String[] values,
boolean[] numeric)
throws SQLException
SQLException - if the row could not be added.
public static String getLongString(ResultSet rs,
int pos)
throws SQLException
SQLException
public static void createNonExistingTables(ConnectionPool cPool,
InputStream dbSpec)
throws IOException,
InconsistentTableSpecException,
SQLException
IOException
InconsistentTableSpecException
SQLException
protected abstract ConnectionPool i_getConnectionPool(DatastoreConfiguration cpDC)
throws SQLException
SQLException
protected abstract void i_replaceInto(Connection conn,
String table,
String[] columns,
String[] values,
String uniqueColumn,
boolean[] numeric)
throws SQLException
SQLException
protected abstract boolean i_updateRow(Connection conn,
String table,
String[] columns,
String[] values,
String uniqueColumn,
boolean[] numeric)
throws SQLException
SQLException
protected abstract void i_addRow(Connection conn,
String table,
String[] columns,
String[] values,
boolean[] numeric)
throws SQLException
SQLException
protected abstract void i_createNonExistingTables(ConnectionPool pool,
InputStream dbSpec)
throws IOException,
InconsistentTableSpecException,
SQLException
IOException
InconsistentTableSpecException
SQLException
protected abstract List<TableSpec> i_getNonExistingTables(Connection conn,
List<TableSpec> specs)
throws SQLException
SQLException
protected abstract void i_createTables(TableCreatingConnection tcConn,
List<TableSpec> specs)
throws SQLException
SQLException
protected abstract String i_getLongString(ResultSet rs,
int pos)
throws SQLException
SQLException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||