## gate.persist
Class JDBCDataStore

    java.lang.Object
      |
      +--gate.util.AbstractFeatureBearer
            |
            +--gate.persist.JDBCDataStore

All Implemented Interfaces:
  CreoleListener, DatabaseDataStore, DataStore, EventListener, FeatureBearer, NameBearer, Serializable

Direct Known Subclasses:
  OracleDataStore

public abstract class JDBCDataStore
extends AbstractFeatureBearer
implements DatabaseDataStore, CreoleListener

See Also:
  Serialized Form

Field Summary
`protected AccessController` `ac`
`private Vector` `datastoreListeners`
`private String` `dbID`
`private String` `dbURL` ---
`private static boolean` `DEBUG` ---
`protected Vector` `dependentResources`
`private String` `driverName`
`protected Connection` `jdbcConn`
`protected String` `name`
`protected Session` `session`

Fields inherited from class gate.util.AbstractFeatureBearer
`features, serialVersionUID`

Fields inherited from interface gate.DataStore
`DATASTORE_FEATURE_NAME, LR_ID_FEATURE_NAME`

Constructor Summary
`protected` `JDBCDataStore()` Do not use this class directly - use one of the subclasses

Method Summary
`void` `addDatastoreListener(DatastoreListener l)` Registers a new `DatastoreListener` with this datastore
`abstract LanguageResource` `adopt(LanguageResource lr, SecurityInfo secInfo)` Adopt a resource for persistence.
`void` `beginTrans()` ---
`abstract boolean` `canReadLR(Object lrID)` Checks if the user (identified by the sessionID) has read access to the LR
`abstract boolean` `canWriteLR(Object lrID)` Checks if the user (identified by the sessionID) has write access to the LR
`void` `close()` Close the data store.
`void` `commitTrans()` ---
`void` `create()` Create a new data store.
`void` `datastoreClosed(CreoleEvent e)` Called when a `DataStore` has been closed
`void` `datastoreCreated(CreoleEvent e)` Called when a `DataStore` has been created
`void` `datastoreOpened(CreoleEvent e)` Called when a `DataStore` has been opened
`void` `delete()` Delete the data store.
`abstract void` `delete(String lrClassName, Object lrId)` Delete a resource from the data store.
`void` `deleteSince(Long timestamp)` ---
`protected int` `findFeatureType(Object value)` ---
`protected void` `fireResourceAdopted(DatastoreEvent e)`
`protected void` `fireResourceDeleted(DatastoreEvent e)`
`protected void` `fireResourceWritten(DatastoreEvent e)`
`abstract String` `getComment()` Returns the comment displayed by the GUI for this DataStore
`String` `getDatabaseID()` ---
`abstract String` `getIconName()` Returns the name of the icon to be used when this datastore is displayed in the GUI
`abstract LanguageResource` `getLr(String lrClassName, Object lrPersistenceId)` Get a resource from the persistent store.
`abstract List` `getLrIds(String lrType)` Get a list of the IDs of LRs of a particular type that are present.
`abstract String` `getLrName(Object lrId)` Get the name of an LR from its ID.
`abstract List` `getLrNames(String lrType)` Get a list of the names of LRs of a particular type that are present.
`abstract List` `getLrTypes()` Get a list of the types of LR that are present in the data store.
`String` `getName()` Returns the name of this resource
`Session` `getSession(Session s)` identify user using this datastore
`String` `getStorageUrl()` Get the URL for the underlying storage mechanism.
`boolean` `isAutoSaving()` Get the autosaving behaviour of the LR.
`void` `open()` Open a connection to the data store.
`abstract String` `readDatabaseID()` ---
`void` `removeDatastoreListener(DatastoreListener l)` Removes a a previously registered `DatastoreListener` from the list listeners for this datastore
`void` `resourceLoaded(CreoleEvent e)` Called when a new `Resource` has been loaded into the system
`void` `resourceUnloaded(CreoleEvent e)` Called when a `Resource` has been removed from the system
`void` `rollbackTrans()` ---
`void` `setAutoSaving(boolean autoSaving)` Set method for the autosaving behaviour of the data store.
`void` `setDriver(String driverName)` ---
`void` `setName(String name)` Sets the name of this resource
`void` `setSession(Session s)` identify user using this datastore
`void` `setStorageUrl(String storageUrl)` Set the URL for the underlying storage mechanism.
`abstract void` `sync(LanguageResource lr)` Save: synchonise the in-memory image of the LR with the persistent image.
`Long` `timestamp()` ---

Methods inherited from class gate.util.AbstractFeatureBearer
`getFeatures, setFeatures`

Methods inherited from class java.lang.Object
`<clinit>, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait`

Methods inherited from interface gate.DataStore
`getSecurityInfo, lockLr, setSecurityInfo, unlockLr`

Methods inherited from interface gate.util.FeatureBearer
`getFeatures, setFeatures`

Field Detail

### DEBUG

    private static final boolean DEBUG

  ---

### dbURL

    private String dbURL

  ---

### driverName

    private String driverName

### dbID

    private String dbID

### session

    protected Session session

### name

    protected String name

### jdbcConn

    protected transient Connection jdbcConn

### ac

    protected transient AccessController ac

### datastoreListeners

    private transient Vector datastoreListeners

### dependentResources

    protected transient Vector dependentResources

Constructor Detail

### JDBCDataStore

    protected JDBCDataStore()

  Do not use this class directly - use one of the subclasses

Method Detail

### getComment

    public abstract String getComment()

  Returns the comment displayed by the GUI for this DataStore
  Specified by:
    `getComment` in interface `DataStore`

### getIconName

    public abstract String getIconName()

  Returns the name of the icon to be used when this datastore is displayed in the GUI
  Specified by:
    `getIconName` in interface `DataStore`

### getLrName

    public abstract String getLrName(Object lrId)
                              throws PersistenceException

  Get the name of an LR from its ID.
  Specified by:
    `getLrName` in interface `DataStore`

### setStorageUrl

    public void setStorageUrl(String storageUrl)
                       throws PersistenceException

  Set the URL for the underlying storage mechanism.
  Specified by:
    `setStorageUrl` in interface `DataStore`

### getStorageUrl

    public String getStorageUrl()

  Get the URL for the underlying storage mechanism.
  Specified by:
    `getStorageUrl` in interface `DataStore`

### create

    public void create()
                throws PersistenceException,
                       UnsupportedOperationException

  Create a new data store. NOTE: for some data stores creation is an system administrator task; in such cases this method will throw an UnsupportedOperationException.
  Specified by:
    `create` in interface `DataStore`

### open

    public void open()
              throws PersistenceException

  Open a connection to the data store.
  Specified by:
    `open` in interface `DataStore`

### close

    public void close()
               throws PersistenceException

  Close the data store.
  Specified by:
    `close` in interface `DataStore`

### delete

    public void delete()
                throws PersistenceException,
                       UnsupportedOperationException

  Delete the data store. NOTE: for some data stores deletion is an system administrator task; in such cases this method will throw an UnsupportedOperationException.
  Specified by:
    `delete` in interface `DataStore`

### delete

    public abstract void delete(String lrClassName,
                                Object lrId)
                         throws PersistenceException,
                                SecurityException

  Delete a resource from the data store.
  Specified by:
    `delete` in interface `DataStore`
  Parameters:
    `lrId` - a data-store specific unique identifier for the resource
    `lrClassName` - class name of the type of resource

### sync

    public abstract void sync(LanguageResource lr)
                       throws PersistenceException,
                              SecurityException

  Save: synchonise the in-memory image of the LR with the persistent image.
  Specified by:
    `sync` in interface `DataStore`

### setAutoSaving

    public void setAutoSaving(boolean autoSaving)
                       throws UnsupportedOperationException,
                              PersistenceException

  Set method for the autosaving behaviour of the data store. NOTE: many types of datastore have no auto-save function, in which case this will throw an UnsupportedOperationException.
  Specified by:
    `setAutoSaving` in interface `DataStore`

### isAutoSaving

    public boolean isAutoSaving()

  Get the autosaving behaviour of the LR.
  Specified by:
    `isAutoSaving` in interface `DataStore`

### adopt

    public abstract LanguageResource adopt(LanguageResource lr,
                                           SecurityInfo secInfo)
                                    throws PersistenceException,
                                           SecurityException

  Adopt a resource for persistence.
  Specified by:
    `adopt` in interface `DataStore`

### getLr

    public abstract LanguageResource getLr(String lrClassName,
                                           Object lrPersistenceId)
                                    throws PersistenceException,
                                           SecurityException

  Get a resource from the persistent store. Don't use this method - use Factory.createResource with DataStore and DataStoreInstanceId parameters set instead.
  Specified by:
    `getLr` in interface `DataStore`

### getLrTypes

    public abstract List getLrTypes()
                             throws PersistenceException

  Get a list of the types of LR that are present in the data store.
  Specified by:
    `getLrTypes` in interface `DataStore`

### getLrIds

    public abstract List getLrIds(String lrType)
                           throws PersistenceException

  Get a list of the IDs of LRs of a particular type that are present.
  Specified by:
    `getLrIds` in interface `DataStore`

### getLrNames

    public abstract List getLrNames(String lrType)
                             throws PersistenceException

  Get a list of the names of LRs of a particular type that are present.
  Specified by:
    `getLrNames` in interface `DataStore`

### canReadLR

    public abstract boolean canReadLR(Object lrID)
                               throws PersistenceException,
                                      SecurityException

  Checks if the user (identified by the sessionID) has read access to the LR
  Specified by:
    `canReadLR` in interface `DataStore`

### canWriteLR

    public abstract boolean canWriteLR(Object lrID)
                                throws PersistenceException,
                                       SecurityException

  Checks if the user (identified by the sessionID) has write access to the LR
  Specified by:
    `canWriteLR` in interface `DataStore`

### beginTrans

    public void beginTrans()
                    throws PersistenceException,
                           UnsupportedOperationException

  ---
  Specified by:
    `beginTrans` in interface `DatabaseDataStore`

### commitTrans

    public void commitTrans()
                     throws PersistenceException,
                            UnsupportedOperationException

  ---
  Specified by:
    `commitTrans` in interface `DatabaseDataStore`

### rollbackTrans

    public void rollbackTrans()
                       throws PersistenceException,
                              UnsupportedOperationException

  ---
  Specified by:
    `rollbackTrans` in interface `DatabaseDataStore`

### timestamp

    public Long timestamp()
                   throws PersistenceException

  ---
  Specified by:
    `timestamp` in interface `DatabaseDataStore`

### deleteSince

    public void deleteSince(Long timestamp)
                     throws PersistenceException

  ---
  Specified by:
    `deleteSince` in interface `DatabaseDataStore`

### setDriver

    public void setDriver(String driverName)
                   throws PersistenceException

  ---
  Specified by:
    `setDriver` in interface `DatabaseDataStore`

### setName

    public void setName(String name)

  Sets the name of this resource
  Specified by:
    `setName` in interface `NameBearer`

### getName

    public String getName()

  Returns the name of this resource
  Specified by:
    `getName` in interface `NameBearer`

### findFeatureType

    protected int findFeatureType(Object value)

  ---

### getDatabaseID

    public String getDatabaseID()

  ---
  Specified by:
    `getDatabaseID` in interface `DatabaseDataStore`

### readDatabaseID

    public abstract String readDatabaseID()
                                   throws PersistenceException

  ---

### removeDatastoreListener

    public void removeDatastoreListener(DatastoreListener l)

  Removes a a previously registered `DatastoreListener` from the list listeners for this datastore
  Specified by:
    `removeDatastoreListener` in interface `DataStore`

### addDatastoreListener

    public void addDatastoreListener(DatastoreListener l)

  Registers a new `DatastoreListener` with this datastore
  Specified by:
    `addDatastoreListener` in interface `DataStore`

### fireResourceAdopted

    protected void fireResourceAdopted(DatastoreEvent e)

### fireResourceDeleted

    protected void fireResourceDeleted(DatastoreEvent e)

### fireResourceWritten

    protected void fireResourceWritten(DatastoreEvent e)

### resourceLoaded

    public void resourceLoaded(CreoleEvent e)

  Description copied from interface: `CreoleListener`
  Called when a new `Resource` has been loaded into the system
  Specified by:
    `resourceLoaded` in interface `CreoleListener`

### resourceUnloaded

    public void resourceUnloaded(CreoleEvent e)

  Description copied from interface: `CreoleListener`
  Called when a `Resource` has been removed from the system
  Specified by:
    `resourceUnloaded` in interface `CreoleListener`

### datastoreOpened

    public void datastoreOpened(CreoleEvent e)

  Description copied from interface: `CreoleListener`
  Called when a `DataStore` has been opened
  Specified by:
    `datastoreOpened` in interface `CreoleListener`

### datastoreCreated

    public void datastoreCreated(CreoleEvent e)

  Description copied from interface: `CreoleListener`
  Called when a `DataStore` has been created
  Specified by:
    `datastoreCreated` in interface `CreoleListener`

### datastoreClosed

    public void datastoreClosed(CreoleEvent e)

  Description copied from interface: `CreoleListener`
  Called when a `DataStore` has been closed
  Specified by:
    `datastoreClosed` in interface `CreoleListener`

### setSession

    public void setSession(Session s)
                    throws SecurityException

  identify user using this datastore
  Specified by:
    `setSession` in interface `DataStore`

### getSession

    public Session getSession(Session s)
                       throws SecurityException

  identify user using this datastore
  Specified by:
    `getSession` in interface `DataStore`