|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--gate.util.AbstractFeatureBearer | +--gate.persist.SerialDataStore | +--gate.db.Database
Objects of type Database are used to connect to a database. They hold all the necessary information for accessing the database and provide services to client objects (i.e. persistent language resources).
Field Summary | |
protected List |
availableConnections
|
protected String |
catalog
|
protected List |
connections
|
private static boolean |
DEBUG
Debug flag |
protected Map |
dictionary
|
protected Driver |
driver
|
protected FeatureMap |
features
|
protected String |
password
|
protected String |
schema
|
static int |
TRANSACTION_LEVEL
|
protected String |
url
|
protected String |
user
|
Fields inherited from class gate.persist.SerialDataStore |
autoSaving, currentProtocolVersion, datastoreListeners, protocolVersionNumbers, randomiser, storageDir, versionFileName, versionNumber |
Constructor Summary | |
Database(Driver driver,
String url,
String user,
String password,
String catalog,
String schema)
Constructs an object of type database. |
Method Summary | |
protected void |
connect()
This method needs to be called before any access is provided to the database. |
void |
deleteFeaturesOf(long ownerId,
Connection con)
Deletes from the Gate2 database all the features belonging to the object with the given id. |
String |
getCatalog()
Returns the 'catalog' associated with this database object. |
Connection |
getConnection()
This method is used by the clients of this Database object in order to gain access to the database. |
Map |
getDictionary()
|
FeatureMap |
getFeatures()
Gets the features of this datastore. |
String |
getSchema()
Returns the 'schema' value associated with this database object. |
boolean |
isConnected()
Used to find out if this Database object is actually connected to a database. |
void |
putObject(PreparedStatement ps,
int place,
Object value)
Acts as a setBlob for the provided prepared statement on the position indicated by place. |
FeatureMap |
readFeaturesOf(long ownerId,
Connection con)
This method reads (from the Gate2 database) the features of the object bearing the given ID. |
Object |
readObjectBlob(ResultSet rs,
Connection con,
String columnName)
Reads a Object from a BLOB on the current row in a result set. |
void |
release()
Frees the allocated resources (closes all the open connections). |
void |
setFeatures(FeatureMap features)
Sets the features of this datastore. |
void |
takeBackConnection(Connection con)
Takes back a previously supplied connection and makes it available for other clients. |
void |
writeFeaturesOf(long ownerId,
FeatureMap featuresToWrite,
Connection con)
This method writes the given FeatureMap as features belonging to the object with the given offset. |
Methods inherited from class gate.persist.SerialDataStore |
addDatastoreListener, adopt, close, constructPersistenceId, create, delete, delete, equals, fireResourceAdopted, fireResourceDeleted, fireResourceWritten, getLr, getLrIds, getLrName, getLrNames, getLrTypes, getStorageDir, getStorageUrl, getVersionFile, hashCode, isAutoSaving, isValidProtocolVersion, open, random, removeDatastoreListener, setAutoSaving, setStorageDir, setStorageUrl, sync, toString |
Methods inherited from class gate.util.AbstractFeatureBearer |
getName, setName |
Methods inherited from class java.lang.Object |
|
Methods inherited from interface gate.util.FeatureBearer |
getName, setName |
Field Detail |
private static final boolean DEBUG
protected List connections
protected List availableConnections
protected Driver driver
protected String url
protected String user
protected String password
protected FeatureMap features
protected String catalog
protected String schema
protected Map dictionary
public static int TRANSACTION_LEVEL
Constructor Detail |
public Database(Driver driver, String url, String user, String password, String catalog, String schema)
driver
- an object of type java.sql.Driver. The driver used for
JDBC access to the database.url
- the JDBC url that identifies the database this object
should connect to.user
- The user name for accessing the database.password
- The passwordfor accessing the database.catalog
- The catalog where the tables will be found.schema
- The schema where the tables will be found.Method Detail |
protected void connect()
public Connection getConnection()
public void takeBackConnection(Connection con) throws GateException
con
- the connection being returned.
If the connection was not provided by this Database object, an exception
will be raised.public void setFeatures(FeatureMap features)
setFeatures
in class AbstractFeatureBearer
features
- a value of type 'FeatureMap'public FeatureMap getFeatures()
getFeatures
in class AbstractFeatureBearer
public boolean isConnected()
public void release() throws OpenTransactionsException
OpenTransactionsException
- if there are any connections
that haven't been returned by the clients of this database.public Object readObjectBlob(ResultSet rs, Connection con, String columnName) throws SQLException, IOException
rs
- a result set positioned on the row from which the BLOB is to
be readcolumnName
- the name of the column containing the BLOB on the
current row.SQLException
- if an error occurs.public void putObject(PreparedStatement ps, int place, Object value) throws SQLException, IOException
ps
- A prepared statement where the blob will be set.place
- The position on the prepared statement where the blob
will be set.value
- The object that will be serialised and converted into a blob.public FeatureMap readFeaturesOf(long ownerId, Connection con) throws SQLException, IOException
ownerId
- a value of type 'long' representing the id of
the object for which the features are to be retrieved.con
- a value of type 'Connection' which should be connceted
to the database from which the features are to be read.SQLException
- if an error occurspublic void writeFeaturesOf(long ownerId, FeatureMap featuresToWrite, Connection con) throws SQLException, IOException
ownerId
- a value of type 'long' representing the offset of the
owner of the feature map.featuresToWrite
- the FeatureMap to be written.con
- A connection to the Gate2 database.SQLException
- if an error occurspublic void deleteFeaturesOf(long ownerId, Connection con) throws SQLException
ownerId
- a value of type 'long' representing the database ID
of the object for which the features are to be erased.con
- a connection to the Gate2 database.SQLException
- if an error occurspublic String getCatalog()
public String getSchema()
public Map getDictionary()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |