DriverManagerConnectionFactory (Apache Tomcat 10.1.57 API Documentation)
Description: declaration: package: org.apache.tomcat.dbcp.dbcp2, class: DriverManagerConnectionFactory

# Class DriverManagerConnectionFactory

java.lang.Object
org.apache.tomcat.dbcp.dbcp2.DriverManagerConnectionFactory

All Implemented Interfaces:
  `ConnectionFactory`

public class DriverManagerConnectionFactory extends Object implements ConnectionFactory
A `DriverManager`-based implementation of `ConnectionFactory`.

Since:
  2.0

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `DriverManagerConnectionFactory(String connectionUri)`
  Constructor for DriverManagerConnectionFactory.
  `DriverManagerConnectionFactory(String connectionUri, String userName, char[] userPassword)`
  Constructor for DriverManagerConnectionFactory.
  `DriverManagerConnectionFactory(String connectionUri, String userName, String userPassword)`
  Constructor for DriverManagerConnectionFactory.
  `DriverManagerConnectionFactory(String connectionUri, Properties properties)`
  Constructor for DriverManagerConnectionFactory.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Connection`
  `createConnection()`
  Create a new `Connection` in an implementation specific fashion.
  `String`
  `getConnectionUri()`
  Gets the connection URI.
  `Properties`
  `getProperties()`
  Gets the Properties, may be null.
  `String`
  `getUserName()`
  Gets the user name, may be null.

  ### Methods inherited from class Object

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

- ## Constructor Details

  - ### DriverManagerConnectionFactory

    public DriverManagerConnectionFactory(String connectionUri)
    Constructor for DriverManagerConnectionFactory.
    Parameters:
      `connectionUri` - a database connection string of the form `jdbc:<em>subprotocol</em>:<em>subname</em>`
    Since:
      2.2

  - ### DriverManagerConnectionFactory

    public DriverManagerConnectionFactory(String connectionUri, Properties properties)
    Constructor for DriverManagerConnectionFactory.
    Parameters:
      `connectionUri` - a database connection string of the form `jdbc:<em>subprotocol</em>:<em>subname</em>`
      `properties` - a list of arbitrary string tag/value pairs as connection arguments; normally at least a "user" and "password" property should be included.

  - ### DriverManagerConnectionFactory

    public DriverManagerConnectionFactory(String connectionUri, String userName, char[] userPassword)
    Constructor for DriverManagerConnectionFactory.
    Parameters:
      `connectionUri` - a database connection string of the form `jdbc:<em>subprotocol</em>:<em>subname</em>`
      `userName` - the database user
      `userPassword` - the user's password

  - ### DriverManagerConnectionFactory

    public DriverManagerConnectionFactory(String connectionUri, String userName, String userPassword)
    Constructor for DriverManagerConnectionFactory.
    Parameters:
      `connectionUri` - a database connection string of the form `jdbc:<em>subprotocol</em>:<em>subname</em>`
      `userName` - the database user
      `userPassword` - the user's 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

  - ### getConnectionUri

    public String getConnectionUri()
    Gets the connection URI.
    Returns:
      The connection URI.
    Since:
      2.6.0

  - ### getProperties

    public Properties getProperties()
    Gets the Properties, may be null.
    Returns:
      The Properties, may be null.
    Since:
      2.6.0

  - ### getUserName

    public String getUserName()
    Gets the user name, may be null.
    Returns:
      The user name, may be null.
    Since:
      2.6.0