public class OADataSourceJDBC extends OADataSource
OADataSourceJDBC has a lot of settings that can be used to set up how the JDBC Driver and SQL needs to work. By setting the type of Database, these values will automatically be set.
Modifier and Type | Field and Description |
---|---|
protected ConnectionPool |
connectionPool |
protected Database |
database |
protected DBMetaData |
dbmd |
bAssignNumberOnCreate, bEnable, bLast, dataSourceChangeCnter, guid, name
Constructor and Description |
---|
OADataSourceJDBC(Database database,
DBMetaData dbmd)
Create new OADataSourceJDBC using a Database mapping object.
|
Modifier and Type | Method and Description |
---|---|
void |
assignId(OAObject object)
Set all properties that are mapped to a column to NULL
|
void |
close()
Close all Connections.
|
void |
closeAllConnections()
Close all Connections.
|
int |
count(Class selectClass,
String queryWhere,
Object[] params,
OAObject whereObject,
String propertyFromWhereObject,
String extraWhere,
int max)
Perform a count on the DataSource using a query.
|
int |
countPassthru(Class selectClass,
String queryWhere,
int max)
Performs a count using native query language for DataSource.
|
void |
delete(OAObject object)
Remove an Object from a DataSource.
|
Object |
execute(String command)
Execute a command on the dataSource.
|
boolean |
getAllowIdChange()
returns false
|
Connection |
getConnection()
Get a jdbc Connection from Connection Pool.
|
Connection |
getConnection(boolean bExclusive) |
ConnectionPool |
getConnectionPool() |
Database |
getDatabase()
Returns database mapping object.
|
DBMetaData |
getDBMetaData() |
void |
getInfo(Vector vec)
Adds Strings to Vector, listing information about DataSource.
|
ArrayList<ManyToMany> |
getManyToMany(OALinkInfo linkInfo)
Select the objectKeys from a link table.
|
int |
getMaxLength(Class c,
String propertyName)
Returns max length allowed for a property.
|
Object |
getObject(OAObjectInfo oi,
Class clazz,
OAObjectKey key,
boolean bDirty) |
PreparedStatement |
getPreparedStatement(String sql)
Returns a JDBC PreparedStatement from connection pool.
|
PreparedStatement |
getPreparedStatement(String sql,
boolean bHasAutoGenerated) |
byte[] |
getPropertyBlobValue(OAObject obj,
String propertyName)
Select BLOB (large byte[]) property
|
Statement |
getStatement()
Returns a JDBC Statement from connection pool.
|
Statement |
getStatement(String message)
Returns a JDBC Statement from connection pool.
|
void |
insert(OAObject object)
Add/Insert a new Object into DataSource.
|
void |
insertWithoutReferences(OAObject obj)
Add/Insert a new Object into DataSource, without references (fkeys).
|
boolean |
isAvailable()
Used to know is datasoure is currently available.
|
boolean |
isClassSupported(Class clazz,
OAFilter filter)
Returns true if Database has Table that is mapped to Class.
|
void |
releaseConnection(Connection connection) |
void |
releasePreparedStatement(PreparedStatement ps)
Releases a JDBC PreparedStatement from connection pool.
|
void |
releasePreparedStatement(PreparedStatement ps,
boolean bCanBeReused) |
void |
releaseStatement(Statement statement)
release a JDBC Statement from connection pool.
|
void |
reopen(int pos)
This can be called after a close has been done to make the datasoruce available again.
|
OADataSourceIterator |
select(Class selectClass,
String queryWhere,
Object[] params,
String queryOrder,
OAObject whereObject,
String propertyFromWhereObject,
String extraWhere,
int max,
OAFilter filter,
boolean bDirty)
Perform a query to retrieve objects from DataSource.
|
OADataSourceIterator |
selectPassthru(Class selectClass,
String queryWhere,
String queryOrder,
int max,
OAFilter filter,
boolean bDirty)
Performs a select using native query language for DataSource.
|
void |
setDBMetaData(DBMetaData dbmd) |
void |
setGuid(String guid)
Seed value to use when creating GUID for seq assigned object keys.
|
void |
setNextNumber(Class c,
int nextNumberToUse) |
boolean |
supportsStorage()
Returns true, this datasource supports selecting/storing/deleting
|
void |
update(OAObject object,
String[] includeProperties,
String[] excludeProperties)
Update an existing Object to DataSource.
|
void |
updateMany2ManyLinks(OAObject masterObject,
OAObject[] adds,
OAObject[] removes,
String propFromMaster)
Used by dataSources to update special requirements for handling Many2Many relationships (ex:Link Table).
|
boolean |
verify() |
boolean |
willCreatePropertyValue(OAObject object,
String propertyName)
Called by OAObject.getRequiredProperties() to find required properties that are unassigned.
|
closeAll, count, count, count, count, count, count, count, count, count, count, countPassthru, countPassthru, finalize, getAssignIdOnCreate, getChangeCounter, getDataSource, getDataSource, getDataSources, getEnabled, getGuid, getInfo, getName, getObject, getObject, getObject, getObject, getObject, getPosition, getSupportsPreCount, isClassSupported, removeFromList, save, select, select, select, select, select, select, select, select, select, select, select, select, select, select, select, select, select, select, selectPassthru, selectPassthru, selectPassthru, selectPassthru, selectPassthru, setAssignIdOnCreate, setEnabled, setLast, setName, setPosition, toString, update
protected DBMetaData dbmd
protected Database database
protected ConnectionPool connectionPool
public OADataSourceJDBC(Database database, DBMetaData dbmd)
public Database getDatabase()
public DBMetaData getDBMetaData()
public void setDBMetaData(DBMetaData dbmd)
public ConnectionPool getConnectionPool()
public boolean supportsStorage()
supportsStorage
in interface OADataSourceInterface
supportsStorage
in class OADataSource
public boolean isAvailable()
OADataSource
isAvailable
in interface OADataSourceInterface
isAvailable
in class OADataSource
public boolean getAllowIdChange()
getAllowIdChange
in interface OADataSourceInterface
getAllowIdChange
in class OADataSource
public boolean isClassSupported(Class clazz, OAFilter filter)
isClassSupported
in interface OADataSourceInterface
isClassSupported
in class OADataSource
clazz
- classfilter
- used to query the datasourcepublic void getInfo(Vector vec)
getInfo
in class OADataSource
public void assignId(OAObject object)
assignId
in interface OADataSourceInterface
assignId
in class OADataSource
public void setNextNumber(Class c, int nextNumberToUse)
public void update(OAObject object, String[] includeProperties, String[] excludeProperties)
OADataSource
Called directly by OAObject.save()
update
in interface OADataSourceInterface
update
in class OADataSource
public void insert(OAObject object)
OADataSource
Called directly by OAObject.save()
insert
in interface OADataSourceInterface
insert
in class OADataSource
public void insertWithoutReferences(OAObject obj)
OADataSource
Called directly by OAObject.saveWithoutReferences() to save a reference while saving another Object.
insertWithoutReferences
in interface OADataSourceInterface
insertWithoutReferences
in class OADataSource
OAObject.save()
public void delete(OAObject object)
OADataSource
delete
in interface OADataSourceInterface
delete
in class OADataSource
public void updateMany2ManyLinks(OAObject masterObject, OAObject[] adds, OAObject[] removes, String propFromMaster)
OADataSource
Uses the hub.masterObject, Hub.getRemovedObjects(), Hub.getAddedObjects()
to find out which objects were added or removed.
This is called by OAObject.cascadeSave/Delete methods
updateMany2ManyLinks
in interface OADataSourceInterface
updateMany2ManyLinks
in class OADataSource
public boolean willCreatePropertyValue(OAObject object, String propertyName)
willCreatePropertyValue
in interface OADataSourceInterface
willCreatePropertyValue
in class OADataSource
public OADataSourceIterator select(Class selectClass, String queryWhere, Object[] params, String queryOrder, OAObject whereObject, String propertyFromWhereObject, String extraWhere, int max, OAFilter filter, boolean bDirty)
OADataSource
See OASelect for complete description on selects/queriess.
select
in interface OADataSourceInterface
select
in class OADataSource
filter
- not used, since the jdbc ds supports queries.selectClass
- Class of object to create and returnqueryWhere
- query String using property paths based on Object structure. DataSourceparams
- list of values to replace '?' in queryWhere clause.queryOrder
- sort orderwhereObject
- master object to select from.extraWhere
- added to the query.bDirty
- true if objects should be fully populated, even if they are already loaded (in cache, etc).OASelect
public OADataSourceIterator selectPassthru(Class selectClass, String queryWhere, String queryOrder, int max, OAFilter filter, boolean bDirty)
OADataSource
selectPassthru
in interface OADataSourceInterface
selectPassthru
in class OADataSource
selectClass
- Class of object to create and returnqueryWhere
- query based on DataSource structure.OASelect
public Object execute(String command)
OADataSource
execute
in interface OADataSourceInterface
execute
in class OADataSource
command
- DataSource native command.public int count(Class selectClass, String queryWhere, Object[] params, OAObject whereObject, String propertyFromWhereObject, String extraWhere, int max)
OADataSource
count
in interface OADataSourceInterface
count
in class OADataSource
selectClass
- Class to perform query onqueryWhere
- query using property paths based on Object structure.OASelect
public int countPassthru(Class selectClass, String queryWhere, int max)
OADataSource
countPassthru
in interface OADataSourceInterface
countPassthru
in class OADataSource
queryWhere
- query based on DataSource structure.OASelect
public Statement getStatement()
public Statement getStatement(String message)
public void releaseStatement(Statement statement)
public PreparedStatement getPreparedStatement(String sql)
public PreparedStatement getPreparedStatement(String sql, boolean bHasAutoGenerated)
public void releasePreparedStatement(PreparedStatement ps)
public void releasePreparedStatement(PreparedStatement ps, boolean bCanBeReused)
public void close()
close
in interface OADataSourceInterface
close
in class OADataSource
public void reopen(int pos)
OADataSource
reopen
in interface OADataSourceInterface
reopen
in class OADataSource
pos
- search location in list of datasources.public void closeAllConnections()
public Connection getConnection() throws Exception
Exception
public Connection getConnection(boolean bExclusive) throws Exception
Exception
public void releaseConnection(Connection connection)
public byte[] getPropertyBlobValue(OAObject obj, String propertyName)
OADataSource
getPropertyBlobValue
in interface OADataSourceInterface
getPropertyBlobValue
in class OADataSource
public Object getObject(OAObjectInfo oi, Class clazz, OAObjectKey key, boolean bDirty)
getObject
in interface OADataSourceInterface
getObject
in class OADataSource
public int getMaxLength(Class c, String propertyName)
OADataSource
getMaxLength
in interface OADataSourceInterface
getMaxLength
in class OADataSource
public void setGuid(String guid)
OADataSource
setGuid
in class OADataSource
public ArrayList<ManyToMany> getManyToMany(OALinkInfo linkInfo)
Copyright © 1999–2019 ViaOA. All rights reserved.