org.persvr.datasource
Class DatabaseDataSource
java.lang.Object
org.persvr.datasource.BaseDataSource
org.persvr.datasource.DatabaseDataSource
- All Implemented Interfaces:
- DataSource
- Direct Known Subclasses:
- DatabaseTableDataSource, DynaObjectDBSource, DynaObjectDBSource
public abstract class DatabaseDataSource
- extends BaseDataSource
- Author:
- Kris Zyp
This provides a default starting implementation for JDBC database sources
| Fields inherited from class org.persvr.datasource.BaseDataSource |
BINARY_HEADER, BOOLEAN_FALSE, BOOLEAN_TRUE, DATE_HEADER, DECIMAL_HEADER, DOUBLE_HEADER, FUNCTION_HEADER, INTEGER_HEADER, LINK_HEADER, LONG_HEADER, OBJECT_HEADER, REQUIRED_PREFIX, STRING_HEADER, UNDEFINED |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
connectionString
protected java.lang.String connectionString
DatabaseDataSource
public DatabaseDataSource()
runStarterStatements
protected void runStarterStatements()
throws java.sql.SQLException
- Throws:
java.sql.SQLException
initParameters
public void initParameters(java.util.Map<java.lang.String,java.lang.Object> parameters)
throws java.lang.Exception
- Description copied from interface:
DataSource
- This is called on initialization and provides access to the data source configuration parameters
- Throws:
java.lang.Exception
getConnectionObject
protected DatabaseDataSource.ThreadSpecificConnectionObject getConnectionObject()
- This will return a thread specific connection object. It will create a new one if necessary
- Returns:
-
- Throws:
java.sql.SQLException
createConnection
protected java.sql.Connection createConnection()
throws java.sql.SQLException
- Throws:
java.sql.SQLException
tryExecution
public java.lang.Object tryExecution(DatabaseDataSource.DatabaseAction action)
throws java.sql.SQLException
- This will attempt to perform the given action. If it fails, it will try to create a new connection and try again.
- Parameters:
action -
- Throws:
java.sql.SQLException
testLocks
public void testLocks()
executeAndGetGeneratedKey
public long executeAndGetGeneratedKey(java.sql.PreparedStatement statement,
java.lang.String tableName)
throws java.sql.SQLException
- Throws:
java.sql.SQLException
commitTransaction
public void commitTransaction()
throws java.sql.SQLException
- Throws:
java.sql.SQLException
startTransaction
public void startTransaction()
throws java.sql.SQLException
- Throws:
java.sql.SQLException
abortTransaction
public void abortTransaction()
throws java.sql.SQLException
- Throws:
java.sql.SQLException
comparison
protected java.lang.String comparison(Node expression,
Node valueNode,
int conditionType)
nameInQuery
protected abstract java.lang.String nameInQuery(java.lang.String name)
numberComparisonInQuery
protected java.lang.String numberComparisonInQuery(double number,
java.lang.String operator)
stringComparisonInQuery
protected java.lang.String stringComparisonInQuery(java.lang.String str)
addConditionToQuery
protected java.lang.String addConditionToQuery(Node condition)
throws java.sql.SQLException
- Converts a JSONPath/JavaScript AST condition to SQL
- Parameters:
condition -
- Returns:
-
- Throws:
java.sql.SQLException
getValueFromRs
protected abstract java.lang.Object getValueFromRs(java.sql.ResultSet rs)
throws java.lang.Exception
- This gets the value/object for the current result set row
- Parameters:
rs -
- Returns:
-
- Throws:
java.lang.Exception