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

## org.huihoo.jfox.datasource
Class PoolDataSource

    org.huihoo.jfox.datasource.PoolDataSource

All Implemented Interfaces:
  Component, ComponentSupportMBean, Loggable, javax.naming.spi.ObjectFactory, Persistentable, PoolDataSourceMBean, javax.naming.Referenceable, java.io.Serializable

public class PoolDataSource
implements javax.naming.Referenceable, javax.naming.spi.ObjectFactory, PoolDataSourceMBean

Author:
  Kelvin Wu
See Also:
  Serialized Form

Field Summary
`protected SimpleConnectionPool` | `pool`

Constructor Summary
`PoolDataSource()` Default constructor used by JNDI to get a new Instance without any parameters.
`PoolDataSource(java.lang.String dbDriver, java.lang.String dbURL, java.lang.String user, java.lang.String password)` Constructor specify database connection parameters to generate a valid and usable datasource.

Method Summary
`protected void` | `doDestroy()`
`protected void` | `doInit()`
`java.sql.Connection` | `getConnection()` Get usable connection from datasource
`java.sql.Connection` | `getConnection(java.lang.String username, java.lang.String password)` Get connection by specific user name and password, the connection is not pooled by Connection Pool
`java.lang.String` | `getDbDriver()`
`java.lang.String` | `getDbURL()`
`int` | `getLoginTimeout()`
`java.io.PrintWriter` | `getLogWriter()` Get logger writer
`java.lang.Object` | `getObjectInstance(java.lang.Object obj, javax.naming.Name name, javax.naming.Context nameCtx, java.util.Hashtable environment)` Method that inherited from ObjectFactory.
`java.lang.String` | `getPassword()`
`javax.naming.Reference` | `getReference()` Method that inherited from Referenceable.
`java.lang.String` | `getUser()`
`void` | `setDbDriver(java.lang.String dbDriver)`
`void` | `setDbURL(java.lang.String dbURL)`
`void` | `setLoginTimeout(int seconds)`
`void` | `setLogWriter(java.io.PrintWriter out)`
`void` | `setPassword(java.lang.String password)`
`void` | `setUser(java.lang.String user)`

Methods inherited from interface org.huihoo.jfox.service.ComponentSupportMBean
`getObjectName, getProxyInstance`

Methods inherited from interface org.huihoo.jfox.service.Component
`destroy, getName, getState, init`

Methods inherited from interface org.huihoo.jfox.service.Loggable
`getLogger`

Field Detail

### pool

    protected SimpleConnectionPool pool

Constructor Detail

### PoolDataSource

    public PoolDataSource()

  Default constructor used by JNDI to get a new Instance without any parameters.

### PoolDataSource

    public PoolDataSource(java.lang.String dbDriver,
                          java.lang.String dbURL,
                          java.lang.String user,
                          java.lang.String password)
                   throws java.lang.Exception

  Constructor specify database connection parameters to generate a valid and usable datasource.
  Parameters:
    `dbDriver` - database class name according your dabase
    `dbURL` - database url used to access database
    `user` - valid database user
    `password` - // corresponding database password
  Throws:
    `java.lang.Exception` - any exception who cares?

Method Detail

### getConnection

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

  Get usable connection from datasource
  Returns:
    Connection the valid database connection can used by user
  Throws:
    `java.sql.SQLException` -

### getConnection

    public java.sql.Connection getConnection(java.lang.String username,
                                             java.lang.String password)
                                      throws java.sql.SQLException

  Get connection by specific user name and password, the connection is not pooled by Connection Pool
  Parameters:
    `username` -
    `password` -
  Returns:
  Throws:
    `java.sql.SQLException` -

### getLogWriter

    public java.io.PrintWriter getLogWriter()
                                     throws java.sql.SQLException

  Get logger writer
  Returns:
  Throws:
    `java.sql.SQLException` -

### setLogWriter

    public void setLogWriter(java.io.PrintWriter out)
                      throws java.sql.SQLException

  Parameters:
    `out` -
  Throws:
    `java.sql.SQLException` -

### setLoginTimeout

    public void setLoginTimeout(int seconds)
                         throws java.sql.SQLException

  Parameters:
    `seconds` -
  Throws:
    `java.sql.SQLException` -

### getLoginTimeout

    public int getLoginTimeout()
                        throws java.sql.SQLException

  Returns:
  Throws:
    `java.sql.SQLException` -

### getReference

    public javax.naming.Reference getReference()
                                        throws javax.naming.NamingException

  Method that inherited from Referenceable.
  Specified by:
    `getReference` in interface `javax.naming.Referenceable`
  Returns:
  Throws:
    `javax.naming.NamingException` -

### getObjectInstance

    public java.lang.Object getObjectInstance(java.lang.Object obj,
                                              javax.naming.Name name,
                                              javax.naming.Context nameCtx,
                                              java.util.Hashtable environment)
                                       throws java.lang.Exception

  Method that inherited from ObjectFactory.
  Specified by:
    `getObjectInstance` in interface `javax.naming.spi.ObjectFactory`
  Parameters:
    `obj` -
    `name` -
    `nameCtx` -
    `environment` -
  Returns:
  Throws:
    `java.lang.Exception` -

### getDbDriver

    public java.lang.String getDbDriver()

  Specified by:
    `getDbDriver` in interface `PoolDataSourceMBean`

### setDbDriver

    public void setDbDriver(java.lang.String dbDriver)

  Specified by:
    `setDbDriver` in interface `PoolDataSourceMBean`

### getDbURL

    public java.lang.String getDbURL()

  Specified by:
    `getDbURL` in interface `PoolDataSourceMBean`

### setDbURL

    public void setDbURL(java.lang.String dbURL)

  Specified by:
    `setDbURL` in interface `PoolDataSourceMBean`

### getUser

    public java.lang.String getUser()

  Specified by:
    `getUser` in interface `PoolDataSourceMBean`

### setUser

    public void setUser(java.lang.String user)

  Specified by:
    `setUser` in interface `PoolDataSourceMBean`

### getPassword

    public java.lang.String getPassword()

  Specified by:
    `getPassword` in interface `PoolDataSourceMBean`

### setPassword

    public void setPassword(java.lang.String password)

  Specified by:
    `setPassword` in interface `PoolDataSourceMBean`

### doInit

    protected void doInit()
                   throws java.lang.Exception

### doDestroy

    protected void doDestroy()
                      throws java.lang.Exception

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