DBPostgres
Keywords: uk.ac.ic.doc.automed.util.db.DBPostgres class

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## uk.ac.ic.doc.automed.util.db
Class DBPostgres

    java.lang.Object
      uk.ac.ic.doc.automed.util.db.DBAccess
          uk.ac.ic.doc.automed.util.db.DBPostgres

    public class DBPostgres

extends DBAccess

Field Summary

Fields inherited from class uk.ac.ic.doc.automed.util.db.DBAccess
`connections, dbFQPath, password, props, user`

Method Summary
`void` | `commit()` Only use this method if you want to commit changes immediately. In HSQLDB this can be avoided by using "SET _writeDelay 0 MILLIS" in dbname.script file.
`protected void` | `executeCommand(java.lang.String cmd)` Mostly used for executing control commands, e.g.
`java.sql.ResultSet` | `executeQuery(java.lang.String expression)` This method is used for SELECT statement
`void` | `executeStatement(java.lang.String expression)` This method is used for making changes to data, e.g.
`java.sql.Connection` | `getConnection()`
`static DBPostgres` | `getDBInstance(java.lang.String dbFQPath, java.lang.String user, java.lang.String password, java.util.Properties props)` Create a new DB process instance for a data source named `dsName`. As such, we can initiate multiple databases (data sources) at the same time.
`boolean` | `isTableExist(java.lang.String name)` Return a result set of table names for manipulation
`java.sql.Connection` | `newConnection()` Creates a new connection to add to the pool
`void` | `printResultSet(java.sql.ResultSet rs)` A test method to print in simple tabular form a result set
`void` | `setAutoCommit(boolean autoCommit)` Different data sources understands auto-commit differently.

Methods inherited from class uk.ac.ic.doc.automed.util.db.DBAccess
`closeConnection, getCurrentRow, shutdown`

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

Method Detail

### getDBInstance

    public static DBPostgres getDBInstance(java.lang.String dbFQPath,
                                           java.lang.String user,
                                           java.lang.String password,
                                           java.util.Properties props)
                                    throws DBInstanceException

  Create a new DB process instance for a data source named `dsName`.
  As such, we can initiate multiple databases (data sources) at the same time.

  Parameters:
    `dbFQPath` - the fully qualified path to data source
    `user` - user to connect to
    `password` - password associated to user
    `props` - a `Properties` object specifying extra properties
    E.g. HSQLDB may requires write_delay = 0 for auto-commit
  Throws:
    `DBInstanceException`

### newConnection

    public java.sql.Connection newConnection()
                                      throws java.sql.SQLException

  Description copied from class: `DBAccess`
  Creates a new connection to add to the pool

  Overrides:
    `newConnection` in class `DBAccess`
  Throws:
    `java.sql.SQLException`

### getConnection

    public java.sql.Connection getConnection()

  Specified by:
    `getConnection` in class `DBAccess`

### setAutoCommit

    public void setAutoCommit(boolean autoCommit)
                       throws java.sql.SQLException

  Different data sources understands auto-commit differently. This method
  tries to encapsulate the operation to set auto-commit

  Specified by:
    `setAutoCommit` in class `DBAccess`
  Parameters:
    `autoCommit` - a `boolean` value: true = auto-commit; false otherwise
  Throws:
    `java.sql.SQLException`

### commit

    public void commit()
                throws java.sql.SQLException

  Only use this method if you want to commit changes immediately.
  In HSQLDB this can be avoided by using "SET _writeDelay 0 MILLIS" in dbname.script
  file.

  Specified by:
    `commit` in class `DBAccess`
  Throws:
    `java.sql.SQLException`

### executeQuery

    public java.sql.ResultSet executeQuery(java.lang.String expression)
                                    throws java.sql.SQLException

  This method is used for SELECT statement

  Specified by:
    `executeQuery` in class `DBAccess`
  Parameters:
    `expression` - is an SQL statement to use
  Returns:
    `ResultSet` object of the result data
  Throws:
    `java.sql.SQLException`

### executeStatement

    public void executeStatement(java.lang.String expression)
                          throws java.sql.SQLException

  This method is used for making changes to data, e.g. INSERT, DELETE, UPDATE

  Specified by:
    `executeStatement` in class `DBAccess`
  Parameters:
    `expression` - is an SQL statement to use
  Throws:
    `java.sql.SQLException`

### executeCommand

    protected void executeCommand(java.lang.String cmd)
                           throws java.sql.SQLException

  Mostly used for executing control commands, e.g. SHUTDOWN, SET ...

  Overrides:
    `executeCommand` in class `DBAccess`
  Parameters:
    `cmd` - the command to execute
  Throws:
    `java.sql.SQLException`

### isTableExist

    public boolean isTableExist(java.lang.String name)
                         throws java.sql.SQLException

  Return a result set of table names for manipulation

  Overrides:
    `isTableExist` in class `DBAccess`
  Throws:
    `java.sql.SQLException`

### printResultSet

    public void printResultSet(java.sql.ResultSet rs)
                        throws java.sql.SQLException

  A test method to print in simple tabular form a result set

  Overrides:
    `printResultSet` in class `DBAccess`
  Throws:
    `java.sql.SQLException`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD