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

## util.sql
Class ConnectionManager

    java.lang.Object
      util.sql.ConnectionManager

    public class ConnectionManager

extends java.lang.Object

creates a pool of connections to DB for performance reasons

Field Summary
`private java.util.Vector<java.sql.Connection>` | `connectionPool`
`private java.lang.String` | `databaseUrl`
`private java.lang.String` | `driver`
`private int` | `MAX_POOL_SIZE`
`private java.lang.String` | `password`
`private java.lang.String` | `username`

Constructor Summary
`ConnectionManager()` Constructor default
`ConnectionManager(java.lang.String driver, java.lang.String databaseUrl, java.lang.String username, java.lang.String password, int maxPoolSize)`

Method Summary
`private boolean` | `checkIfConnectionPoolIsFull()`
`boolean` | `connectionSuccess()`
`private java.sql.Connection` | `createNewConnectionForPool()` creates new connection to db
`java.sql.Connection` | `getConnectionFromPool()`
`private void` | `initializeConnectionPool()` fills connectionPool with connections for numConnections < MAX_POOL_SIZE
`void` | `returnConnectionToPool(java.sql.Connection connection)` Adding the connection from the client back to the connectionPool

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

Field Detail

### driver

    private java.lang.String driver

### databaseUrl

    private java.lang.String databaseUrl

### username

    private java.lang.String username

### password

    private java.lang.String password

### connectionPool

    private java.util.Vector<java.sql.Connection> connectionPool

### MAX_POOL_SIZE

    private int MAX_POOL_SIZE

Constructor Detail

### ConnectionManager

    public ConnectionManager()

  Constructor default

### ConnectionManager

    public ConnectionManager(java.lang.String driver,
                             java.lang.String databaseUrl,
                             java.lang.String username,
                             java.lang.String password,
                             int maxPoolSize)

Parameters:
  `driver` - which dbc driver
  `databaseUrl` - -
  `username` - -
  `password` - -
  `maxPoolSize` - - how many db-connection should the ConnectionManager allocate

Method Detail

### initializeConnectionPool

    private void initializeConnectionPool()

  fills connectionPool with connections for numConnections < MAX_POOL_SIZE

### checkIfConnectionPoolIsFull

    private boolean checkIfConnectionPoolIsFull()

  Returns:
    connectionPool.size() < MAX_POOL_SIZE

### createNewConnectionForPool

    private java.sql.Connection createNewConnectionForPool()

  creates new connection to db

  Returns:
    new connection

### getConnectionFromPool

    public java.sql.Connection getConnectionFromPool()

  Returns:
    a connection out of the connectionPool

### returnConnectionToPool

    public void returnConnectionToPool(java.sql.Connection connection)

  Adding the connection from the client back to the connectionPool

  Parameters:
    `connection` - -

### connectionSuccess

    public boolean connectionSuccess()

  Returns:
    true, if there is at least one connection to the db

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