HEADER

ru.biosoft.access
Class SQLDataCollection

ru.biosoft.access.DataElementSupport
  |
  +--ru.biosoft.access.AbstractDataCollection
        |
        +--ru.biosoft.access.SQLDataCollection

public class SQLDataCollection
extends AbstractDataCollection

DataCollection which store all information in SQL DBMS.

Version: 1.0
See Also: DataCollection, SQLTransformer

Field Summary
 final static StringJDBC_DRIVER_PROPERTY
          Property for storing class of jdbc driver.
 final static StringJDBC_PASSWORD_PROPERTY
          Property for storing user password for connecting to the DBMS.
 final static StringJDBC_URL_PROPERTY
          Property for storing driver specific URL for connecting to the DBMS.
 final static StringJDBC_USER_PROPERTY
          Property for storing user name for connecting to the DBMS.
 final static StringTRANSFORMER_CLASS_PROPERTY
          Property for storing class of that should be used for converting DataElements to/from DBMS.

Constructor Summary
SQLDataCollection(DataCollection parent, Properties properties)
          Standart constructor for creating data collection.

Method Summary
 voidclose()
          Close connection to DBMS.
 booleancontains(String name)
          Return is DataElement with such name exists in the data collection.
 ClassgetDataElementType()
          Return type of DataElement stored in this data collection.
 final StringgetDriverClassName()
          Return driver class name for DB connection.
 final StringgetPassword()
          Return Password for DB connection.
 intgetSize()
          Return size of data collection.
 final StringgetUrl()
          Return URL for DB connection.
 final StringgetUser()
          Return User for DB connection.
 voidinit()
          Called before any other method.
 booleanisMutable()
          Returns true if this data collection is mutable.
 Iteratoriterator()
          Returns an iterator over the data elements in this collection.
 DataElementput(DataElement element)
          Adds the specified data element to the collection.

Methods inherited from class ru.biosoft.access.AbstractDataCollection
addDataCollectionListener, contains, get, getCompleteName, getInfo, getNameList, propagateElementChanged, propagateElementWillChange, remove, removeDataCollectionListener, toString

Methods inherited from class ru.biosoft.access.DataElementSupport
getName, getOrigin, registerConstructorWithBadEqual

Field Detail

JDBC_DRIVER_PROPERTY

public final static String JDBC_DRIVER_PROPERTY
Property for storing class of jdbc driver.

JDBC_PASSWORD_PROPERTY

public final static String JDBC_PASSWORD_PROPERTY
Property for storing user password for connecting to the DBMS.

JDBC_URL_PROPERTY

public final static String JDBC_URL_PROPERTY
Property for storing driver specific URL for connecting to the DBMS.

JDBC_USER_PROPERTY

public final static String JDBC_USER_PROPERTY
Property for storing user name for connecting to the DBMS.

TRANSFORMER_CLASS_PROPERTY

public final static String TRANSFORMER_CLASS_PROPERTY
Property for storing class of that should be used for converting DataElements to/from DBMS.
Constructor Detail

SQLDataCollection

public SQLDataCollection(DataCollection parent, Properties properties)
throws java.lang.ClassNotFoundException,
java.sql.SQLException,
java.lang.IllegalAccessException,
java.lang.InstantiationException
Standart constructor for creating data collection. Used by CollectionFactory.
Parameters:
parent - Parent collection.
properties - Properties for creating collection (cannot be null).
See Also:
JDBC_DRIVER_PROPERTY, JDBC_URL_PROPERTY, JDBC_USER_PROPERTY, JDBC_PASSWORD_PROPERTY, TRANSFORMER_CLASS_PROPERTY, CollectionFactory, AbstractDataCollection
Method Detail

close

public void close()
throws java.lang.Exception
Close connection to DBMS. Invalidates SQLDataCollection instance.
Throws:
Exception

contains

public boolean contains(String name)
Return is DataElement with such name exists in the data collection.
Parameters:
name - Name of DataElement.
Returns: Is data colection contains DataElement with specified name.
See Also:
AbstractDataCollection.get(java.lang.String)

getDataElementType

public Class getDataElementType()
Return type of DataElement stored in this data collection. Really ask transformer for extract template type.
Returns: Type of DataElement stored in this data collection.
See Also:
SQLTransformer

getDriverClassName

public final String getDriverClassName()
Return driver class name for DB connection.
Returns: Driver class name for DB connection.
See Also:
JDBC_DRIVER_PROPERTY

getPassword

public final String getPassword()
Return Password for DB connection.
Returns: Password for DB connection.
See Also:
JDBC_PASSWORD_PROPERTY

getSize

public int getSize()
Return size of data collection. This implementation execute SQL query for extract record count.
Returns: Size of data collection.

getUrl

public final String getUrl()
Return URL for DB connection.
Returns: URL for DB connection.
See Also:
JDBC_URL_PROPERTY

getUser

public final String getUser()
Return User for DB connection.
Returns: User for DB connection.
See Also:
JDBC_USER_PROPERTY

init

public void init()
Called before any other method.

isMutable

public boolean isMutable()
Returns true if this data collection is mutable. Check Connection is read only or not.
Returns: Is collection mutable?
See Also:
Connection

iterator

public Iterator iterator()
Returns an iterator over the data elements in this collection. There are no guarantees concerning the order in which the elements are returned. If the data collection is modified while an iteration over it is in progress, the results of the iteration are undefined.
See Also:
SQLDataCollection.SQLIterator

put

public DataElement put(DataElement element)
throws java.lang.Exception
Adds the specified data element to the collection. Notifies all listeners if the data element was added or changed. doInsert and doUpdate methods is used to put or change the data element. If the data collection previously contained the specified element, the old value is replaced. If DataCollectionVeto was thrown then element not added, but previous element will be returned.
Parameters:
element - DataElement which will be putted in the collection.
Returns: Previous data element (may be null).
Throws:
java.lang.UnsupportedOperationException - if collection is not mutable.
java.lang.Exception - if cannot extract previous element.
java.sql.SQLException - if DBMS cannot insert or update data element.
See Also:
AbstractDataCollection.get(java.lang.String), doInsert(ru.biosoft.access.DataElement), doUpdate(ru.biosoft.access.DataElement), DataCollectionVetoException

Association Links

to Class java.lang.String

Property for storing class of jdbc driver.

to Class java.lang.String

Property for storing driver specific URL for connecting to the DBMS.

to Class java.lang.String

Property for storing user name for connecting to the DBMS.

to Class java.lang.String

Property for storing user password for connecting to the DBMS.

to Class java.lang.String

Property for storing class of that should be used for converting DataElements to/from DBMS.

to Class ru.biosoft.access.SQLTransformer

Transformer for converting DataElements to/from DBMS.

to Class java.sql.Connection

Connection to DBMS.

to Class java.lang.String

Class of used DB driver

to Class java.lang.String

URL for database connection

to Class java.lang.String

User for database connection

to Class java.lang.String

Password for database connection

FOOTER

BOTTOM