Package org.opennms.core.db
Class C3P0ConnectionFactory
- java.lang.Object
-
- org.opennms.core.db.BaseConnectionFactory
-
- org.opennms.core.db.C3P0ConnectionFactory
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,java.sql.Wrapper
,javax.sql.CommonDataSource
,javax.sql.DataSource
,ClosableDataSource
public class C3P0ConnectionFactory extends BaseConnectionFactory
C3P0ConnectionFactory class.
-
-
Field Summary
Fields Modifier and Type Field Description static org.slf4j.Logger
LOG
-
Constructor Summary
Constructors Constructor Description C3P0ConnectionFactory(JdbcDataSource dataSource)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
closejava.sql.Connection
getConnection()
java.sql.Connection
getConnection(java.lang.String username, java.lang.String password)
javax.sql.DataSource
getDataSource()
getDataSourceint
getLoginTimeout()
getLoginTimeoutjava.io.PrintWriter
getLogWriter()
java.util.logging.Logger
getParentLogger()
java.lang.String
getUrl()
getUrljava.lang.String
getUser()
getUserprotected void
initializePool(JdbcDataSource dataSource)
void
setIdleTimeout(int idleTimeout)
How long, in seconds, an idle connection is kept in the pool before it is removed.void
setLoginTimeout(int seconds)
How long, in seconds, to attempt to make a connection to the database.void
setLogWriter(java.io.PrintWriter out)
void
setMaxPool(int maxPool)
The maximum number of pooled connections to retain.void
setMaxSize(int maxSize)
The maximum number of connections that can be created.void
setMinPool(int minPool)
The minimum number of pooled connections to retain.void
setUrl(java.lang.String url)
setUrlvoid
setUser(java.lang.String user)
setUser-
Methods inherited from class org.opennms.core.db.BaseConnectionFactory
isWrapperFor, unwrap, validateJdbcUrl
-
-
-
-
Constructor Detail
-
C3P0ConnectionFactory
public C3P0ConnectionFactory(JdbcDataSource dataSource) throws java.beans.PropertyVetoException, java.sql.SQLException
- Throws:
java.beans.PropertyVetoException
java.sql.SQLException
-
-
Method Detail
-
initializePool
protected void initializePool(JdbcDataSource dataSource) throws java.sql.SQLException
- Specified by:
initializePool
in classBaseConnectionFactory
- Throws:
java.sql.SQLException
-
getConnection
public java.sql.Connection getConnection() throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
getUrl
public java.lang.String getUrl()
Description copied from class:BaseConnectionFactory
getUrl
- Specified by:
getUrl
in classBaseConnectionFactory
- Returns:
- a
String
object.
-
setUrl
public void setUrl(java.lang.String url)
Description copied from class:BaseConnectionFactory
setUrl
- Specified by:
setUrl
in classBaseConnectionFactory
- Parameters:
url
- aString
object.
-
getUser
public java.lang.String getUser()
Description copied from class:BaseConnectionFactory
getUser
- Specified by:
getUser
in classBaseConnectionFactory
- Returns:
- a
String
object.
-
setUser
public void setUser(java.lang.String user)
Description copied from class:BaseConnectionFactory
setUser
- Specified by:
setUser
in classBaseConnectionFactory
- Parameters:
user
- aString
object.
-
getDataSource
public javax.sql.DataSource getDataSource()
Description copied from class:BaseConnectionFactory
getDataSource
- Specified by:
getDataSource
in classBaseConnectionFactory
- Returns:
- a
DataSource
object.
-
getConnection
public java.sql.Connection getConnection(java.lang.String username, java.lang.String password) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
getLogWriter
public java.io.PrintWriter getLogWriter() throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
setLogWriter
public void setLogWriter(java.io.PrintWriter out) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
setLoginTimeout
public void setLoginTimeout(int seconds) throws java.sql.SQLException
Description copied from interface:ClosableDataSource
How long, in seconds, to attempt to make a connection to the database.- Throws:
java.sql.SQLException
-
getLoginTimeout
public int getLoginTimeout() throws java.sql.SQLException
Description copied from class:BaseConnectionFactory
getLoginTimeout
- Specified by:
getLoginTimeout
in interfacejavax.sql.CommonDataSource
- Specified by:
getLoginTimeout
in interfacejavax.sql.DataSource
- Specified by:
getLoginTimeout
in classBaseConnectionFactory
- Returns:
- a int.
- Throws:
java.sql.SQLException
- if any.
-
getParentLogger
public java.util.logging.Logger getParentLogger() throws java.sql.SQLFeatureNotSupportedException
- Throws:
java.sql.SQLFeatureNotSupportedException
-
close
public void close()
Description copied from class:BaseConnectionFactory
close
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfaceClosableDataSource
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classBaseConnectionFactory
-
setIdleTimeout
public void setIdleTimeout(int idleTimeout)
Description copied from interface:ClosableDataSource
How long, in seconds, an idle connection is kept in the pool before it is removed.
-
setMinPool
public void setMinPool(int minPool)
Description copied from interface:ClosableDataSource
The minimum number of pooled connections to retain.
-
setMaxPool
public void setMaxPool(int maxPool)
Description copied from interface:ClosableDataSource
The maximum number of pooled connections to retain.
-
setMaxSize
public void setMaxSize(int maxSize)
Description copied from interface:ClosableDataSource
The maximum number of connections that can be created.
-
-