Save This Page
Home » openjdk-7 » net.bereza » db » [javadoc | source]
net.bereza.db
public class: GenericDatabaseItemFactory [javadoc | source]
java.lang.Object
   net.bereza.db.GenericDatabaseItemFactory

All Implemented Interfaces:
    DatabaseItemFactory

Direct Known Subclasses:
    PostgresDatabaseItemFactory

GenericDatabaseItemFactory does the actual database access.

Calling it a factory is a bit of a mis-nomer, but I didn't care much for peer either.

Nested Class Summary:
class  GenericDatabaseItemFactory.IdleChecker   
Field Summary
public static  long IDLE_LIMIT    how long to allow idleness before closure, in minutes 
protected  DateFormat dateFormatter    DateFormat object used by this Factory.

By default this should be for ISO format strings. 

protected  String dbUrl    JDBC URL to the database. 
protected  Properties dbProps    Properties used for connecting to Database. 
protected transient  int connectionCount    Number of threads which are currently using the connection. 
protected transient  Connection conn    Connection used to access database. Same for all access through this factory. 
protected transient  boolean closeConnection    If true then the current connection should be closed when getConnection() is called. 
protected transient  DatabaseMetaData dbMetaData    Database meta data information. 
protected transient  PrintWriter log    PrintStream to write error messages to. 
Constructor:
 public GenericDatabaseItemFactory() 
 public GenericDatabaseItemFactory(String url) 
    Construct the factory with the specified JDBC URL.
    Parameters:
    url - URL to access db
 public GenericDatabaseItemFactory(String url,
    Properties props) 
    Construct the factory with the specified URL and Properties for opening the connection.
    Parameters:
    url - URL to access db
    props - Properties for accessing the database
Method from net.bereza.db.GenericDatabaseItemFactory Summary:
close,   deleteFromDatabase,   getConnection,   getConnection,   getDateFormat,   getInstance,   getInstance,   getInstances,   getInstances,   getInstances,   getTimeZone,   newItem,   releaseConnection,   setConnectionAttributes,   setLog,   updateToDatabase
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from net.bereza.db.GenericDatabaseItemFactory Detail:
 public synchronized  void close() throws DatabaseException 
    Close the Factory and any connections to databases and any resources it may be using.

    Note: The factory must be able to automatically reopen any connections if another method is called.

 public  void deleteFromDatabase(DatabaseItem item) throws DatabaseException 
    Delete this item from the database.
 protected Connection getConnection() throws SQLException 
    Get a shared connection object.
 protected synchronized Connection getConnection(boolean shared) throws SQLException 
    Get the Connection object used in this Factory. If the connection is null the Factory will try to reconnect.
 public DateFormat getDateFormat() 
    Get the DateFormat object that DatabaseItems should use for parsing date strings.
 public synchronized DatabaseItem getInstance(String name) throws DatabaseException 
    Create a new DatabaseItem and insert into the database.
 public DatabaseItem getInstance(String name,
    int id) throws DatabaseException 
    Get a DatabaseItem from the database.
 public Vector getInstances(String name,
    String where) throws DatabaseException 
    Get an unsorted Vector of DatabaseItems from the database.
 public Hashtable getInstances(String name,
    String where,
    String field) throws DatabaseException 
    Get a Hashtable of DatabaseItems where the key is a String representation of the value of the specified field.
 public Vector getInstances(String name,
    String where,
    String field,
    boolean up) throws DatabaseException 
    Get a Vector of DatabaseItems from the database.
 public TimeZone getTimeZone() 
    Get the default TimeZone used by the Database.
 protected static DatabaseItem newItem(String name) throws DatabaseException 
    Construct a new DatabaseItem object with the specified class name.
 public synchronized  void releaseConnection(Connection conObj) 
    Release the connection object.
 public  void setConnectionAttributes(String url,
    Properties props) throws DatabaseException 
    Set the connection attributes for the Database Connections.
 public synchronized  void setLog(PrintWriter logStream) 
    Set the PrintStream to write logging info to.
 public  void updateToDatabase(DatabaseItem item) throws DatabaseException 
    Update this item to the database.