DataSourceConnectionFactory (Apache Tomcat 8.5.43 API Documentation)

org.apache.tomcat.dbcp.dbcp2

## Class DataSourceConnectionFactory

- java.lang.Object
- - org.apache.tomcat.dbcp.dbcp2.DataSourceConnectionFactory

- All Implemented Interfaces:
    ConnectionFactory

      public class DataSourceConnectionFactory
      extends java.lang.Object
      implements ConnectionFactory

  A `DataSource`-based implementation of `ConnectionFactory`.
  Since:
    2.0

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `DataSourceConnectionFactory(javax.sql.DataSource dataSource)` Constructs an instance for the given DataSource.
    `DataSourceConnectionFactory(javax.sql.DataSource dataSource, java.lang.String userName, char[] userPassword)` Constructs an instance for the given DataSource.
    `DataSourceConnectionFactory(javax.sql.DataSource dataSource, java.lang.String userName, java.lang.String password)` Constructs an instance for the given DataSource.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.sql.Connection` | `createConnection()` Create a new `Connection` in an implementation specific fashion.
    `javax.sql.DataSource` | `getDataSource()`
    `java.lang.String` | `getUserName()`
    `char[]` | `getUserPassword()`

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

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

- - ### Constructor Detail

    - #### DataSourceConnectionFactory

          public DataSourceConnectionFactory(javax.sql.DataSource dataSource)

      Constructs an instance for the given DataSource.
      Parameters:
        `dataSource` - The DataSource for this factory.

    - #### DataSourceConnectionFactory

          public DataSourceConnectionFactory(javax.sql.DataSource dataSource,
                                     java.lang.String userName,
                                     char[] userPassword)

      Constructs an instance for the given DataSource.
      Parameters:
        `dataSource` - The DataSource for this factory.
        `userName` - The user name.
        `userPassword` - The user password.
      Since:
        2.4.0

    - #### DataSourceConnectionFactory

          public DataSourceConnectionFactory(javax.sql.DataSource dataSource,
                                     java.lang.String userName,
                                     java.lang.String password)

      Constructs an instance for the given DataSource.
      Parameters:
        `dataSource` - The DataSource for this factory.
        `userName` - The user name.
        `password` - The user password.

  - ### Method Detail

    - #### createConnection

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

      Description copied from interface: `ConnectionFactory`
      Create a new `Connection` in an implementation specific fashion.
      Specified by:
        `createConnection` in interface `ConnectionFactory`
      Returns:
        a new `Connection`
      Throws:
        `java.sql.SQLException` - if a database error occurs creating the connection

    - #### getDataSource

          public javax.sql.DataSource getDataSource()

      Returns:
        The data source.
      Since:
        2.6.0

    - #### getUserName

          public java.lang.String getUserName()

      Returns:
        The user name.
      Since:
        2.6.0

    - #### getUserPassword

          public char[] getUserPassword()

      Returns:
        The user password.
      Since:
        2.6.0

Copyright © 2000-2019 Apache Software Foundation. All Rights Reserved.