|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.dspace.storage.rdbms.DatabaseManager
public class DatabaseManager
Executes SQL queries.
| Constructor Summary | |
|---|---|
protected |
DatabaseManager()
Protected Constructor to prevent instantiation except by derived classes. |
| Method Summary | |
|---|---|
static TableRow |
create(Context context,
String table)
Create a new row in the given table, and assigns a unique id. |
static int |
delete(Context context,
String table,
int id)
Delete a table row via its primary key. |
static int |
delete(Context context,
TableRow row)
Delete row from the RDBMS. |
static int |
deleteByValue(Context context,
String table,
String column,
Object value)
Delete all table rows with the given value. |
static TableRow |
find(Context context,
String table,
int id)
Find a table row by its primary key. |
static TableRow |
findByUnique(Context context,
String table,
String column,
Object value)
Find a table row by a unique value. |
static void |
freeConnection(Connection c)
Release resources associated with this connection. |
protected static List |
getColumnNames(ResultSetMetaData meta)
Return the names of all the columns of the ResultSet. |
protected static List |
getColumnNames(String table)
Return the names of all the columns of the given table. |
static Connection |
getConnection()
Obtain an RDBMS connection. |
protected static String |
getPrimaryKeyColumn(String table)
Return the name of the primary key column in the given table. |
static String |
getPrimaryKeyColumn(TableRow row)
Return the name of the primary key column. |
static void |
insert(Context context,
TableRow row)
Insert a table row into the RDBMS. |
protected static void |
loadParameters(PreparedStatement statement,
Object[] parameters)
Iterate over the given parameters and add them to the given prepared statement. |
static void |
loadSql(Reader r)
Load SQL from a reader into the RDBMS. |
static void |
loadSql(String sql)
Load SQL into the RDBMS. |
static TableRowIterator |
query(Context context,
String query,
Object... parameters)
Return an iterator with the results of the query. |
static TableRowIterator |
queryPrepared(PreparedStatement statement)
Return an iterator with the results of executing statement. |
static TableRowIterator |
queryPreparedTable(String table,
PreparedStatement statement)
Return an iterator with the results of executing statement. |
static TableRow |
querySingle(Context context,
String query,
Object... parameters)
Return the single row result to this query, or null if no result. |
static TableRow |
querySingleTable(Context context,
String table,
String query,
Object... parameters)
Return the single row result to this query, or null if no result. |
static TableRowIterator |
queryTable(Context context,
String table,
String query,
Object... parameters)
Return an iterator with the results of the query. |
static TableRow |
row(String table)
Create a table row object that can be passed into the insert method, not commonly used unless the table has a referential integrity constraint. |
static void |
shutdown()
Provide a means for a (web) application to cleanly terminate the connection pool. |
static int |
update(Context context,
TableRow row)
Update changes to the RDBMS. |
static int |
updateQuery(Context context,
String query,
Object... parameters)
Execute an update, insert or delete query. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
protected DatabaseManager()
| Method Detail |
|---|
public static TableRowIterator queryTable(Context context,
String table,
String query,
Object... parameters)
throws SQLException
context - The context objecttable - The name of the table which resultsquery - The SQL queryparameters - A set of SQL parameters to be included in query. The order of
the parameters must correspond to the order of their reference
within the query.
SQLException - If a database error occurs
public static TableRowIterator query(Context context,
String query,
Object... parameters)
throws SQLException
context - The context objectquery - The SQL queryparameters - A set of SQL parameters to be included in query. The order of
the parameters must correspond to the order of their reference
within the query.
SQLException - If a database error occurs
public static TableRowIterator queryPreparedTable(String table,
PreparedStatement statement)
throws SQLException
statement - The prepared statement to execute.table - The name of the table which results
SQLException - If a database error occurs
public static TableRowIterator queryPrepared(PreparedStatement statement)
throws SQLException
statement - The prepared statement to execute.
SQLException - If a database error occurs
public static TableRow querySingle(Context context,
String query,
Object... parameters)
throws SQLException
context - Current DSpace contextquery - The SQL queryparameters - A set of SQL parameters to be included in query. The order of
the parameters must correspond to the order of their reference
within the query.
SQLException - If a database error occurs
public static TableRow querySingleTable(Context context,
String table,
String query,
Object... parameters)
throws SQLException
context - Current DSpace contexttable - The name of the table which resultsquery - The SQL queryparameters - A set of SQL parameters to be included in query. The order of
the parameters must correspond to the order of their reference
within the query.
SQLException - If a database error occurs
public static int updateQuery(Context context,
String query,
Object... parameters)
throws SQLException
context - Current DSpace contextquery - The SQL query to executeparameters - A set of SQL parameters to be included in query. The order of
the parameters must correspond to the order of their reference
within the query.
SQLException - If a database error occurs
public static TableRow create(Context context,
String table)
throws SQLException
context - Current DSpace contexttable - The RDBMS table in which to create the new row
SQLException
public static TableRow find(Context context,
String table,
int id)
throws SQLException
context - Current DSpace contexttable - The table in which to find the rowid - The primary key value
SQLException - If a database error occurs
public static TableRow findByUnique(Context context,
String table,
String column,
Object value)
throws SQLException
context - Current DSpace contexttable - The table to use to find the objectcolumn - The name of the unique columnvalue - The value of the unique column
SQLException - If a database error occurs
public static int delete(Context context,
String table,
int id)
throws SQLException
context - Current DSpace contexttable - The table to delete fromid - The primary key value
SQLException - If a database error occurs
public static int deleteByValue(Context context,
String table,
String column,
Object value)
throws SQLException
context - Current DSpace contexttable - The table to delete fromcolumn - The name of the columnvalue - The value of the column
SQLException - If a database error occurs
public static Connection getConnection()
throws SQLException
SQLException - If a database error occurs, or a connection cannot be
obtained.public static void freeConnection(Connection c)
c - The connection to release
public static TableRow row(String table)
throws SQLException
table - The RDBMS table in which to create the new row
SQLException
public static void insert(Context context,
TableRow row)
throws SQLException
context - Current DSpace contextrow - The row to insert
SQLException - If a database error occurs
public static int update(Context context,
TableRow row)
throws SQLException
context - Current DSpace contextrow - The row to update
SQLException - If a database error occurs
public static int delete(Context context,
TableRow row)
throws SQLException
context - Current DSpace contextrow - The row to delete
SQLException - If a database error occurs
protected static List getColumnNames(String table)
throws SQLException
table - The name of the table
SQLException - If a database error occurs
protected static List getColumnNames(ResultSetMetaData meta)
throws SQLException
meta - The ResultSetMetaData
SQLException - If a database error occurs
public static void loadSql(String sql)
throws SQLException
sql - The SQL to load.
throws SQLException
If a database error occurs
SQLException
public static void loadSql(Reader r)
throws SQLException,
IOException
r - The Reader from which to read the SQL.
SQLException - If a database error occurs
IOException - If an error occurs obtaining data from the reader
public static String getPrimaryKeyColumn(TableRow row)
throws SQLException
row - The TableRow to return the primary key for.
SQLException - If a database error occurs
protected static String getPrimaryKeyColumn(String table)
throws SQLException
table - The name of the RDBMS table
SQLException - If a database error occurs
public static void shutdown()
throws SQLException
SQLException
protected static void loadParameters(PreparedStatement statement,
Object[] parameters)
throws SQLException
statement - The unparameterized statement.parameters - The parameters to be set on the statement.
SQLException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||