Package 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
ADataSource
-based implementation ofConnectionFactory
.- Since:
- 2.0
-
-
Constructor Summary
Constructors Constructor 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.sql.Connection
createConnection()
Create a newConnection
in an implementation specific fashion.javax.sql.DataSource
getDataSource()
java.lang.String
getUserName()
char[]
getUserPassword()
-
-
-
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 newConnection
in an implementation specific fashion.- Specified by:
createConnection
in interfaceConnectionFactory
- 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
-
-