ch.qos.logback.core.db

## Class JNDIConnectionSource

- java.lang.Object
- - ch.qos.logback.core.spi.ContextAwareBase
  - - ch.qos.logback.core.db.ConnectionSourceBase
    - - ch.qos.logback.core.db.JNDIConnectionSource

All Implemented Interfaces:
  ConnectionSource, ContextAware, LifeCycle

    public class JNDIConnectionSource
    extends ConnectionSourceBase

The <id>JNDIConnectionSource</id> is an implementation of `ConnectionSource` that obtains a `DataSource` from a JNDI provider and uses it to obtain a `Connection`. It is primarily designed to be used inside of J2EE application servers or application server clients, assuming the application server supports remote access of `DataSource`s. In this way one can take advantage of connection pooling and whatever other goodies the application server provides.

For more information about this component, please refer to the online manual at http://logback.qos.ch/manual/appenders.html#DBAppender

Author:
  Ray DeCampo

### Field Summary

### Fields inherited from class ch.qos.logback.core.spi.ContextAwareBase

`context`

### Constructor Summary

Constructors
Constructor and Description
`JNDIConnectionSource()`

### Method Summary

All Methods Instance Methods Concrete Methods
`Connection` `getConnection()` Obtain a `Connection` for use.
`String` `getJndiLocation()` Returns the jndiLocation.
`void` `setJndiLocation(String jndiLocation)` Sets the jndiLocation.
`void` `start()`

### Methods inherited from class ch.qos.logback.core.db.ConnectionSourceBase

`discoverConnectionProperties, getPassword, getSQLDialectCode, getUser, isStarted, setPassword, setUser, stop, supportsBatchUpdates, supportsGetGeneratedKeys`

### Methods inherited from class ch.qos.logback.core.spi.ContextAwareBase

`addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, getDeclaredOrigin, getStatusManager, setContext`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### JNDIConnectionSource

    public JNDIConnectionSource()

### Method Detail

#### start

    public void start()

Specified by:
  `start` in interface `LifeCycle`
Overrides:
  `start` in class `ConnectionSourceBase`

#### getConnection

    public Connection getConnection()
                             throws SQLException

Description copied from interface: `ConnectionSource`
Obtain a `Connection` for use. The client is responsible for closing the `Connection` when it is no longer required.

Throws:
  `SQLException` - if a `Connection` could not be obtained

#### getJndiLocation

    public String getJndiLocation()

Returns the jndiLocation.

Returns:
  String

#### setJndiLocation

    public void setJndiLocation(String jndiLocation)

Sets the jndiLocation.

Parameters:
  `jndiLocation` - The jndiLocation to set