|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectde.mathema.pride.AbstractResourceAccessor
public abstract class AbstractResourceAccessor
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface de.mathema.pride.ResourceAccessor |
|---|
ResourceAccessor.AutoKeyMode, ResourceAccessor.Config, ResourceAccessor.DBType |
| Field Summary | |
|---|---|
protected int |
autoKeyMode
|
protected java.text.SimpleDateFormat |
dateFormat
|
protected java.lang.String |
dbPassword
|
protected java.util.Date |
dbSystime
|
protected java.lang.String |
dbType
|
protected java.lang.String |
dbUser
|
protected java.util.Properties |
props
|
protected java.text.SimpleDateFormat |
timeFormat
|
| Fields inherited from interface de.mathema.pride.ResourceAccessor |
|---|
REVISION_ID, SYSTIME_DEFAULT |
| Constructor Summary | |
|---|---|
AbstractResourceAccessor()
|
|
AbstractResourceAccessor(java.util.Properties props)
Create a new AbstractResourceAccessor according to the passed properties. |
|
| Method Summary | |
|---|---|
protected java.lang.Object |
castJavaUtilDate(java.lang.Object value)
This function maps java.util.Date to java.sql.Timestamp, assuming that java.util.Date members are supposed to provide highest possible precision. |
protected java.text.SimpleDateFormat |
commonDateFormat()
Returns a common format for date and/or time values, based on the database type. |
protected static java.lang.String |
escape(java.lang.String raw,
char escapeChar)
Makes '' from single-quotes in the passed string to make it suitable for SQL syntax |
protected java.lang.String |
escapeBackslahes(java.lang.String raw)
Makes double backslashes from single backslashes which is only required for MySQL |
protected static java.lang.String |
escapeQuotes(java.lang.String raw)
Makes '' from single-quotes in the passed string to make it suitable for SQL syntax |
protected java.lang.String |
formatBoolean(java.lang.Boolean value)
|
protected java.lang.String |
formatDate(java.sql.Date date)
Like formatTime(java.sql.Timestamp) but for date values. |
protected java.lang.String |
formatEnum(java.lang.Enum value)
|
java.lang.String |
formatOperator(java.lang.String operator,
java.lang.Object value)
Formats an operator for usage in SQL statements. |
java.lang.Object |
formatPreparedValue(java.lang.Object value)
Converts the passed value for usage in a prepared statement write access function The function currently just runs formatEnum(java.lang.Enum) or castJavaUtilDate(java.lang.Object) |
protected java.lang.String |
formatTime(java.sql.Timestamp time)
Formats a time value into an SQL-suitable string. |
java.lang.String |
formatValue(java.lang.Object value)
Formats the passed object for SQL syntax, e.g. by putting single-quotes arround strings etc. |
java.lang.String[] |
getAutoFields(java.sql.Statement stmt,
java.lang.String[] rawAutoFields)
The function initializes the auto key fetching mode of not yet done by accessing the passed statement's meta data and calling supportsGetGeneratedKeys(). |
java.sql.ResultSet |
getAutoFieldVals(java.sql.Statement stmt,
java.lang.String[] rawAutoFields)
Return the list of auto field values using JDBC's getGeneratedKeys() function on the passed statement. |
java.lang.String |
getDBType()
Returns the type of database as specified by the constructor properties or null if no type is specified at all. |
java.util.Date |
getSystime()
Retrieves the timestamp, that is currently used to identify, that a date has to be replaced by the database server's system time. |
java.lang.String |
getTableName(java.lang.String logicalTableName)
Returns the passed logical table name as physical name |
java.lang.String |
getURL(java.lang.String db)
Retrieves the URL for this DBMS represented by the ResourceAccessor. |
java.lang.String |
getUserName(java.lang.String db)
Retrieves the user name as known to this database represented by the ResourceAccessor. |
boolean |
isLogging()
Returns true if SQL logging is switched on |
protected void |
setAutoCommit(java.sql.Connection con,
boolean state)
|
boolean |
setLogging(Database db,
boolean val)
Switch SQL logging on and off. |
void |
sqlLog(Database db,
java.lang.String operation)
Writes the passed operation to the SQL log, if logging is enabled |
void |
sqlLogError(Database db,
java.sql.SQLException sqlx)
Writes the passed SQL exception to the log, if logging is enabled |
static java.lang.String |
standardOperator(java.lang.String operator,
java.lang.Object value)
Formats an operator for usage in SQL statements. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface de.mathema.pride.ResourceAccessor |
|---|
getConnection, releaseConnection, releaseConnection |
| Field Detail |
|---|
protected java.lang.String dbType
protected java.text.SimpleDateFormat dateFormat
protected java.text.SimpleDateFormat timeFormat
protected java.lang.String dbUser
protected java.lang.String dbPassword
protected java.util.Date dbSystime
protected java.util.Properties props
protected int autoKeyMode
| Constructor Detail |
|---|
public AbstractResourceAccessor(java.util.Properties props)
throws java.lang.Exception
ResourceAccessor.Config for available configuration
properties.
java.lang.Exception
public AbstractResourceAccessor()
throws java.lang.Exception
java.lang.Exception| Method Detail |
|---|
public boolean setLogging(Database db,
boolean val)
setLogging in interface ResourceAccessorval except when toggling doesn't
work. E.g. switching logging on doesn't work if there is no SQL
log file specified.public boolean isLogging()
true if SQL logging is switched on
isLogging in interface ResourceAccessor
public void sqlLog(Database db,
java.lang.String operation)
ResourceAccessor
sqlLog in interface ResourceAccessor
public void sqlLogError(Database db,
java.sql.SQLException sqlx)
ResourceAccessor
sqlLogError in interface ResourceAccessorprotected static java.lang.String escapeQuotes(java.lang.String raw)
protected java.lang.String escapeBackslahes(java.lang.String raw)
protected static java.lang.String escape(java.lang.String raw,
char escapeChar)
protected java.lang.String formatBoolean(java.lang.Boolean value)
protected java.text.SimpleDateFormat commonDateFormat()
protected java.lang.String formatDate(java.sql.Date date)
formatTime(java.sql.Timestamp) but for date values. This function is
synchronized due to the fact that DateFormat.format is not!!
time - The value to format
protected java.lang.String formatTime(java.sql.Timestamp time)
commonDateFormat(). If there is nothing
to find, it returns the value itself, surrounded by single-quotes. This
function is synchronized due to the fact that DateFormat.format is not!!
time - The value to format
protected java.lang.String formatEnum(java.lang.Enum value)
protected java.lang.Object castJavaUtilDate(java.lang.Object value)
public java.lang.String formatValue(java.lang.Object value)
formatValue in interface ResourceAccessorformatValue in interface SQLFormatter
public static java.lang.String standardOperator(java.lang.String operator,
java.lang.Object value)
Any - of the operators in SQLExpression.Operatorvalue - The value to apply the operator to before it is formatted
SQLExpression.Operator.EQUAL and "IS NOT" for
operator SQLExpression.Operator.UNEQUAL.
public java.lang.String formatOperator(java.lang.String operator,
java.lang.Object value)
standardOperator(java.lang.String, java.lang.Object) for details
formatOperator in interface ResourceAccessorformatOperator in interface SQLFormatteroperator - Any of the operators defined in SQLExpression.Operatorvalue - The raw value the operator is applied to before it
is formated by ResourceAccessor.formatValue(java.lang.Object). May be null.public java.lang.Object formatPreparedValue(java.lang.Object value)
formatEnum(java.lang.Enum) or castJavaUtilDate(java.lang.Object)
formatPreparedValue in interface ResourceAccessorformatPreparedValue in interface SQLFormatter
public java.lang.String getTableName(java.lang.String logicalTableName)
throws java.lang.Exception
getTableName in interface ResourceAccessorjava.lang.Exception
protected void setAutoCommit(java.sql.Connection con,
boolean state)
throws java.sql.SQLException
java.sql.SQLException
public java.lang.String[] getAutoFields(java.sql.Statement stmt,
java.lang.String[] rawAutoFields)
getAutoFields in interface ResourceAccessorstmt - The statement which is about to be executedrawAutoFields - The auto fields to consider as declared in a descriptor
public java.sql.ResultSet getAutoFieldVals(java.sql.Statement stmt,
java.lang.String[] rawAutoFields)
throws java.sql.SQLException
getAutoFieldVals in interface ResourceAccessorstmt - SQL statement object which was last be used to execute an insertion.rawAutoFields - The auto fields to consider as declared in a descriptor
java.sql.SQLExceptionpublic java.util.Date getSystime()
getSystime in interface ResourceAccessor
public java.lang.String getURL(java.lang.String db)
throws java.lang.Exception
getURL in interface ResourceAccessordb -
java.lang.Exception
public java.lang.String getUserName(java.lang.String db)
throws java.lang.Exception
getUserName in interface ResourceAccessordb -
java.lang.Exceptionpublic java.lang.String getDBType()
getDBType in interface ResourceAccessor
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||