Class JDBCDataSource
java.lang.Object
repast.simphony.freezedry.AbstractDataSource<ResultSet>
repast.simphony.freezedry.datasource.JDBCDataSource
- All Implemented Interfaces:
FreezeDryedDataSource
-
Field Summary
FieldsFields inherited from class repast.simphony.freezedry.AbstractDataSource
ARRAY_MARKER, BYTES_MARKER, CHILD_CLASS_COL, CHILD_ID_COL, CHILD_ID_MARKER, CHILDREN_MARKER, CLASS_MARKER, ID_COL, PARENT_ID_COL, SPECIAL_COL_MARKER -
Constructor Summary
ConstructorsConstructorDescriptionJDBCDataSource(String connectionString, String driverClassName, String userName, String password) JDBCDataSource(DBConnectionInfo info, boolean storeLogin) -
Method Summary
Modifier and TypeMethodDescriptionprotected StringcleanColName(String name) protected voidcloseChildQuery(Class clazz) protected voidcloseQuery(Class clazz) protected voidprotected voidcreateTableIfNeeded(Connection con, FreezeDryedObject fdo) protected voidendTypeRead(Class clazz) Finishes the reading of the specified class.protected voidexecuteCreate(Connection con, String creationSQL) protected voidEnds the reading of the children for the specifiedFreezeDryedObject.protected voidFinishes the writing of the children for the specifiedFreezeDryedObject.protected voidFinishes the writing of the specifiedFreezeDryedObject.protected StringgenerateId(Class<?> clazz) protected StringgenerateId(String className) protected StringgetArrayType(String field) protected ConnectiongetChildConnection(Class clazz, boolean canCreate) protected ConnectiongetChildConnection(FreezeDryedObject fdo, boolean canCreate) protected Stringprotected Stringprotected StringgetClassMapping(String className) protected StringgetColumnType(FreezeDryedObject fdo, String colName) protected Connectionprotected ConnectiongetConnection(Class clazz, boolean canCreate) protected ConnectiongetConnection(FreezeDryedObject fdo, boolean canCreate) getDBURL()Retrieves the fields for a specified type.protected ObjectgetFieldValue(ResultSet row, String field) Retrieves the value of the specified field in the specified row of data.booleanprotected StringgetTableName(String type) protected Stringprotected Stringprotected Stringprotected Stringprotected StringqueryDBForType(String classType) protected byte[]readByteArray(FreezeDryedObject fdo, String field, Object bytesId) Reads in a byte[] that corresponds to the specified bytesId and will be loaded into the specified fdo through the specified field.protected ResultSetreadChildsRow(FreezeDryedObject parent, String id) Reads in a row of data about a child of the specifiedFreezeDryedObject.protected ResultSetReads in a row of data that will be parsed by the use ofAbstractDataSource.getFieldValue(X, String)andAbstractDataSource.getFields(String).voidsetStoreLogin(boolean storeLogin) protected voidInitializes the reading of the children of a specifiedFreezeDryedObject.protected voidInitiates the writing of the children for the specifiedFreezeDryedObject.protected voidstartTypeRead(Class clazz) Initiates the reading of the specified class.protected voidThis is called at the start of a call to write.protected voidstoreClassMapping(String clazz, String id) protected booleanprotected ObjectwriteByteArray(FreezeDryedObject object, String fieldName, byte[] bs) Writes a byte array retrieved from the specifiedFreezeDryedObjectwith the specified fieldName.protected voidwriteChildData(FreezeDryedObject fdo, HashMap<String, Object> child) Writes the data for a child of the specifiedFreezeDryedObject.protected voidwriteRow(FreezeDryedObject fdo, Map<String, Object> row) This writes a row of data out which was generated by the specifiedFreezeDryedObject.Methods inherited from class repast.simphony.freezedry.AbstractDataSource
close, getArrayValue, getColumnKeysetPairs, getColumns, getTrueFieldName, getType, getValue, getValue, getValueArray, pair, parseChildRow, parseRow, read, read, readChildren, readFreezeDryedParentChild, reset, write, writeChildren
-
Field Details
-
DEFAULT_CLASS_MAPPING_TABLE
- See Also:
-
CLASS_NAME_COL
- See Also:
-
classIdMap
-
storeLogin
protected boolean storeLogin
-
-
Constructor Details
-
JDBCDataSource
-
JDBCDataSource
-
JDBCDataSource
-
-
Method Details
-
getValue
- Overrides:
getValuein classAbstractDataSource<ResultSet>
-
getConnection
- Throws:
SQLException
-
getConnection
- Throws:
SQLException
-
getConnection
- Throws:
SQLException
-
getChildConnection
protected Connection getChildConnection(FreezeDryedObject fdo, boolean canCreate) throws SQLException - Throws:
SQLException
-
getChildConnection
- Throws:
SQLException
-
startTypeWrite
Description copied from class:AbstractDataSourceThis is called at the start of a call to write. This should cause any needed preparation for reading this type to occur. It will be followed by calls toAbstractDataSource.writeRow(FreezeDryedObject, Map)and a call toAbstractDataSource.finishTypeWrite(FreezeDryedObject).- Specified by:
startTypeWritein classAbstractDataSource<ResultSet>- Parameters:
fdo- theFreezeDryedObjectwho will begin to be written- Throws:
FreezeDryingException- when there's an error
-
finishTypeWrite
Description copied from class:AbstractDataSourceFinishes the writing of the specifiedFreezeDryedObject. This will be preceded by acall and calls to {@link #writeRow(FreezeDryedObject, Map)} (along with the other child and byte methods).- Specified by:
finishTypeWritein classAbstractDataSource<ResultSet>- Throws:
FreezeDryingException- when there's an error
-
writeRow
Description copied from class:AbstractDataSourceThis writes a row of data out which was generated by the specifiedFreezeDryedObject. This will be preceded by acall and will be followed by calls to {@link #writeRow(FreezeDryedObject, Map)} and a call to {@link #finishTypeWrite(FreezeDryedObject)}.- Specified by:
writeRowin classAbstractDataSource<ResultSet>row- the data for the specifiedFreezeDryedObject- Throws:
FreezeDryingException- when there's an error
-
getTableName
-
getTableName
-
getChildTableName
-
cleanColName
-
createTableIfNeeded
- Throws:
SQLException
-
createChildTableIfNeeded
- Throws:
SQLException
-
getColumnType
-
executeCreate
- Throws:
SQLException
-
startChildrenWrite
Description copied from class:AbstractDataSourceInitiates the writing of the children for the specifiedFreezeDryedObject.- Specified by:
startChildrenWritein classAbstractDataSource<ResultSet>- Parameters:
fdo- thewhose children will be written- Throws:
FreezeDryingException
-
finishChildrenWrite
Description copied from class:AbstractDataSourceFinishes the writing of the children for the specifiedFreezeDryedObject.- Specified by:
finishChildrenWritein classAbstractDataSource<ResultSet>- Throws:
FreezeDryingException
-
getType
- Overrides:
getTypein classAbstractDataSource<ResultSet>
-
queryDBForType
- Throws:
SQLException
-
getType
-
generateId
-
generateId
-
getClassMapping
- Throws:
SQLException
-
storeClassMapping
- Throws:
SQLException
-
writeChildData
protected void writeChildData(FreezeDryedObject fdo, HashMap<String, Object> child) throws FreezeDryingExceptionDescription copied from class:AbstractDataSourceWrites the data for a child of the specifiedFreezeDryedObject.- Specified by:
writeChildDatain classAbstractDataSource<ResultSet>- Parameters:
fdo- the parentchild- the data from the child- Throws:
FreezeDryingException
-
startTypeRead
Description copied from class:AbstractDataSourceInitiates the reading of the specified class. This class represents is of a type that was at some point written out through aFreezeDryedObject.- Specified by:
startTypeReadin classAbstractDataSource<ResultSet>- Parameters:
clazz- the class that was the type returned byFreezeDryedObject.getType()- Throws:
FreezeDryingException
-
validateConnectionSettings
protected boolean validateConnectionSettings() -
endTypeRead
Description copied from class:AbstractDataSourceFinishes the reading of the specified class.- Specified by:
endTypeReadin classAbstractDataSource<ResultSet>- Parameters:
clazz- the class whose reading has completed
-
closeQuery
-
closeChildQuery
-
readRow
Description copied from class:AbstractDataSourceReads in a row of data that will be parsed by the use ofAbstractDataSource.getFieldValue(X, String)andAbstractDataSource.getFields(String). If the data source can find an object with the specified key it should return data for reading that object, otherwise it may return any object.- Specified by:
readRowin classAbstractDataSource<ResultSet>- Parameters:
clazz- the class the data will be used forkey- the key of the object we're looking for, if null it should be ignored- Returns:
- a row of data
- Throws:
FreezeDryingException
-
readByteArray
protected byte[] readByteArray(FreezeDryedObject fdo, String field, Object bytesId) throws FreezeDryingException Description copied from class:AbstractDataSourceReads in a byte[] that corresponds to the specified bytesId and will be loaded into the specified fdo through the specified field.- Specified by:
readByteArrayin classAbstractDataSource<ResultSet>- Parameters:
fdo- the object that the bytes are going to be stored infield- the field the bytes[] are for- Returns:
- the read in byte[]
- Throws:
FreezeDryingException
-
writeByteArray
protected Object writeByteArray(FreezeDryedObject object, String fieldName, byte[] bs) throws FreezeDryingException Description copied from class:AbstractDataSourceWrites a byte array retrieved from the specifiedFreezeDryedObjectwith the specified fieldName.- Specified by:
writeByteArrayin classAbstractDataSource<ResultSet>- Parameters:
object- the source of the datafieldName- the field this data is assosciated withbs- the data itself- Returns:
- the value to be written to the subclass for the fieldName (this could potentially just be an id, or it could just be the bytes themselves)
- Throws:
FreezeDryingException
-
getArrayType
- Overrides:
getArrayTypein classAbstractDataSource<ResultSet>
-
finishChildrenRead
Description copied from class:AbstractDataSourceEnds the reading of the children for the specifiedFreezeDryedObject.- Specified by:
finishChildrenReadin classAbstractDataSource<ResultSet>- Parameters:
fdo- theFreezeDryedObjectwhose children have been read
-
readChildsRow
Description copied from class:AbstractDataSourceReads in a row of data about a child of the specifiedFreezeDryedObject.- Specified by:
readChildsRowin classAbstractDataSource<ResultSet>- Parameters:
parent- the parent of the child that will be readid- the id of the child we're concerned with- Returns:
- a row of data on the child
- Throws:
FreezeDryingException
-
startChildrenRead
Description copied from class:AbstractDataSourceInitializes the reading of the children of a specifiedFreezeDryedObject.- Specified by:
startChildrenReadin classAbstractDataSource<ResultSet>- Parameters:
fdo- theFreezeDryedObjectwhose children will be read- Throws:
FreezeDryingException
-
getFields
Description copied from class:AbstractDataSourceRetrieves the fields for a specified type. Generally these should be read in and stored during theAbstractDataSource.startTypeRead(Class)call.- Specified by:
getFieldsin classAbstractDataSource<ResultSet>- Parameters:
type- the type of theFreezeDryedObject(fromAbstractDataSource.getType(Class)).- Returns:
- the list of fields of that type
- Throws:
FreezeDryingException
-
getFieldValue
Description copied from class:AbstractDataSourceRetrieves the value of the specified field in the specified row of data.- Specified by:
getFieldValuein classAbstractDataSource<ResultSet>- Parameters:
row- the row (returned by#readRow(Class)).field- the field we're reading- Returns:
- the value of that field
- Throws:
FreezeDryingException
-
getChildrenColumnName
- Overrides:
getChildrenColumnNamein classAbstractDataSource<ResultSet>
-
getUserName
-
getPassword
-
getDBURL
-
getDriverName
-
getStoreLogin
public boolean getStoreLogin() -
setStoreLogin
public void setStoreLogin(boolean storeLogin)
-