|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.mycore.backend.sql.MCRSQLConnection
public class MCRSQLConnection
Instances of this class represent a database connection to a relational database like DB2. MCRSQLConnection is a wrapper around java.sql.Connection and provides some convenience methods for easier SQL usage in MyCoRe. There are two types of methods in this class:
doQuery( String),
Connection,
MCRSQLConnectionPool| Field Summary | |
|---|---|
protected Connection |
connection
The wrapped JDBC connection |
protected static Logger |
LOGGER
|
| Constructor Summary | |
|---|---|
MCRSQLConnection()
Creates a new connection. |
|
| Method Summary | |
|---|---|
(package private) void |
close()
Closes this connection to the underlying JDBC datastore. |
(package private) void |
closeJDBCConnection()
|
int |
countRows(String condition)
Executes an SQL "SELECT COUNT(*) FROM" statement on this connection, returning the number of rows that match the condition. |
static boolean |
doesTableExist(String tablename)
Checks existence of table |
MCRSQLRowReader |
doQuery(String query)
Executes an SQL select statement on this connection. |
void |
doUpdate(String statement)
Executes an SQL update statement on this connection. |
boolean |
exists(String condition)
Checks if there are any matching rows for a given SQL condition by executing an SQL select statement on this connection. |
void |
finalize()
|
Connection |
getJDBCConnection()
Returns the underlying JDBC java.sql.Connection object |
String |
getSingleValue(String query)
Executes an SQL select statement on this connection, where the expected result is just a single value of a row. |
static boolean |
justCheckExists(String condition)
Checks if there are any matching rows for a given SQL condition by executing an SQL select statement, using any currently free connection from the pool. |
static int |
justCountRows(String condition)
Executes an SQL "SELECT COUNT(*) FROM" statement, returning the number of rows that match the condition, using any currently free connection from the pool. |
static void |
justDoUpdate(String statement)
Executes an SQL update statement, using any currently free connection from the pool. |
static String |
justGetSingleValue(String query)
Executes an SQL select statement where the expected result is just a single value of a row, using any currently free connection from the pool. |
void |
release()
Releases this connection back to the connection pool, indicating that it is no longer needed by the current task. |
(package private) void |
use()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected Connection connection
protected static Logger LOGGER
| Constructor Detail |
|---|
MCRSQLConnection()
throws MCRPersistenceException
MCRPersistenceExceptionMCRSQLConnectionPool.getConnection()| Method Detail |
|---|
void use()
public void release()
MCRSQLConnectionPool.releaseConnection( MCRSQLConnection )
void close()
throws MCRPersistenceException
MCRPersistenceExceptionMCRSQLConnectionPool.finalize()
void closeJDBCConnection()
throws MCRPersistenceException
MCRPersistenceExceptionpublic void finalize()
finalize in class Objectpublic Connection getJDBCConnection()
public MCRSQLRowReader doQuery(String query)
throws MCRPersistenceException
query - the SQL select statement to be executed
MCRPersistenceException
public void doUpdate(String statement)
throws MCRPersistenceException
statement - the SQL create, insert or delete statement to be executed
MCRPersistenceException
public String getSingleValue(String query)
throws MCRPersistenceException
query - the SQL select statement to be executed
MCRPersistenceException
public int countRows(String condition)
throws MCRPersistenceException
condition - the SQL select statement to be executed, beginning at the SQL
"FROM" keyword
MCRPersistenceException
public boolean exists(String condition)
throws MCRPersistenceException
condition - the condition of an SQL select statement to be executed,
beginning at the SQL "FROM" keyword
MCRPersistenceException
public static void justDoUpdate(String statement)
throws MCRPersistenceException
statement - the SQL create, insert or delete statement to be executed
MCRPersistenceException
public static String justGetSingleValue(String query)
throws MCRPersistenceException
query - the SQL select statement to be executed
MCRPersistenceException
public static int justCountRows(String condition)
throws MCRPersistenceException
condition - the SQL select statement to be executed, beginning at the SQL
"FROM" keyword
MCRPersistenceException
public static boolean justCheckExists(String condition)
throws MCRPersistenceException
condition - the condition of an SQL select statement to be executed,
beginning at the SQL "FROM" keyword
MCRPersistenceException
public static boolean doesTableExist(String tablename)
throws MCRPersistenceException
tablename -
MCRPersistenceException - if the JDBC driver could not be loaded or initial connections
could not be created or can not get a connection
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||