Class DataSourceConnectionFactory

java.lang.Object
org.apache.tomcat.dbcp.dbcp2.DataSourceConnectionFactory
All Implemented Interfaces:
ConnectionFactory

public class DataSourceConnectionFactory extends Object implements ConnectionFactory
A DataSource-based implementation of ConnectionFactory.
Since:
2.0
  • Constructor Details

    • DataSourceConnectionFactory

      public DataSourceConnectionFactory(DataSource dataSource)
      Constructs an instance for the given DataSource.
      Parameters:
      dataSource - The DataSource for this factory.
    • DataSourceConnectionFactory

      public DataSourceConnectionFactory(DataSource dataSource, 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(DataSource dataSource, String userName, 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 Details

    • createConnection

      public Connection createConnection() throws 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:
      SQLException - if a database error occurs creating the connection
    • getDataSource

      public DataSource getDataSource()
      Returns:
      The data source.
      Since:
      2.6.0
    • getUserName

      public String getUserName()
      Returns:
      The user name.
      Since:
      2.6.0
    • getUserPassword

      public char[] getUserPassword()
      Returns:
      The user password.
      Since:
      2.6.0