org.opennms.netmgt.config
Class C3P0ConnectionFactory

java.lang.Object
  extended by org.opennms.netmgt.config.C3P0ConnectionFactory
All Implemented Interfaces:
Wrapper, CommonDataSource, DataSource, ClosableDataSource

public class C3P0ConnectionFactory
extends Object
implements ClosableDataSource

C3P0ConnectionFactory class.

Version:
$Id: $
Author:
ranger

Constructor Summary
protected C3P0ConnectionFactory(InputStream stream, String dsName)
          Constructor for C3P0ConnectionFactory.
protected C3P0ConnectionFactory(Reader rdr, String dsName)
          Constructor for C3P0ConnectionFactory.
protected C3P0ConnectionFactory(String configFile, String dsName)
          Constructor for C3P0ConnectionFactory.
 
Method Summary
 void close()
          close
 Connection getConnection()
          getConnection
 Connection getConnection(String username, String password)
          
 DataSource getDataSource()
          getDataSource
 int getLoginTimeout()
          getLoginTimeout
 PrintWriter getLogWriter()
          getLogWriter
 com.mchange.v2.c3p0.ComboPooledDataSource getPool()
          getPool
 String getUrl()
          getUrl
 String getUser()
          getUser
 boolean isWrapperFor(Class<?> iface)
          isWrapperFor
static JdbcDataSource marshalDataSourceFromConfig(InputStream stream, String dsName)
          marshalDataSourceFromConfig
static JdbcDataSource marshalDataSourceFromConfig(Reader rdr, String dsName)
          marshalDataSourceFromConfig
 void setLoginTimeout(int seconds)
          
 void setLogWriter(PrintWriter out)
          
 void setPool(com.mchange.v2.c3p0.ComboPooledDataSource pool)
          setPool
 void setUrl(String url)
          setUrl
 void setUser(String user)
          setUser
<T> T
unwrap(Class<T> iface)
          unwrap
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

C3P0ConnectionFactory

protected C3P0ConnectionFactory(InputStream stream,
                                String dsName)
                         throws org.exolab.castor.xml.MarshalException,
                                org.exolab.castor.xml.ValidationException,
                                PropertyVetoException,
                                SQLException

Constructor for C3P0ConnectionFactory.

Parameters:
stream - a InputStream object.
dsName - a String object.
Throws:
org.exolab.castor.xml.MarshalException - if any.
org.exolab.castor.xml.ValidationException - if any.
PropertyVetoException - if any.
SQLException - if any.

C3P0ConnectionFactory

protected C3P0ConnectionFactory(Reader rdr,
                                String dsName)
                         throws org.exolab.castor.xml.MarshalException,
                                org.exolab.castor.xml.ValidationException,
                                PropertyVetoException,
                                SQLException

Constructor for C3P0ConnectionFactory.

Parameters:
rdr - a Reader object.
dsName - a String object.
Throws:
org.exolab.castor.xml.MarshalException - if any.
org.exolab.castor.xml.ValidationException - if any.
PropertyVetoException - if any.
SQLException - if any.

C3P0ConnectionFactory

protected C3P0ConnectionFactory(String configFile,
                                String dsName)
                         throws IOException,
                                org.exolab.castor.xml.MarshalException,
                                org.exolab.castor.xml.ValidationException,
                                PropertyVetoException,
                                SQLException

Constructor for C3P0ConnectionFactory.

Parameters:
configFile - a String object.
dsName - a String object.
Throws:
IOException - if any.
org.exolab.castor.xml.MarshalException - if any.
org.exolab.castor.xml.ValidationException - if any.
PropertyVetoException - if any.
SQLException - if any.
Method Detail

marshalDataSourceFromConfig

public static JdbcDataSource marshalDataSourceFromConfig(InputStream stream,
                                                         String dsName)
                                                  throws org.exolab.castor.xml.MarshalException,
                                                         org.exolab.castor.xml.ValidationException

marshalDataSourceFromConfig

Parameters:
stream - a InputStream object.
dsName - a String object.
Returns:
a JdbcDataSource object.
Throws:
org.exolab.castor.xml.MarshalException - if any.
org.exolab.castor.xml.ValidationException - if any.

marshalDataSourceFromConfig

public static JdbcDataSource marshalDataSourceFromConfig(Reader rdr,
                                                         String dsName)
                                                  throws org.exolab.castor.xml.MarshalException,
                                                         org.exolab.castor.xml.ValidationException,
                                                         PropertyVetoException,
                                                         SQLException

marshalDataSourceFromConfig

Parameters:
rdr - a Reader object.
dsName - a String object.
Returns:
a JdbcDataSource object.
Throws:
org.exolab.castor.xml.MarshalException - if any.
org.exolab.castor.xml.ValidationException - if any.
PropertyVetoException - if any.
SQLException - if any.

getConnection

public Connection getConnection()
                         throws SQLException

getConnection

Specified by:
getConnection in interface DataSource
Returns:
a Connection object.
Throws:
SQLException - if any.

getPool

public com.mchange.v2.c3p0.ComboPooledDataSource getPool()

getPool

Returns:
a ComboPooledDataSource object.

setPool

public void setPool(com.mchange.v2.c3p0.ComboPooledDataSource pool)

setPool

Parameters:
pool - a ComboPooledDataSource object.

getUrl

public String getUrl()

getUrl

Returns:
a String object.

setUrl

public void setUrl(String url)

setUrl

Parameters:
url - a String object.

getUser

public String getUser()

getUser

Returns:
a String object.

setUser

public void setUser(String user)

setUser

Parameters:
user - a String object.

getDataSource

public DataSource getDataSource()

getDataSource

Returns:
a DataSource object.

getConnection

public Connection getConnection(String username,
                                String password)
                         throws SQLException

Specified by:
getConnection in interface DataSource
Throws:
SQLException

getLogWriter

public PrintWriter getLogWriter()
                         throws SQLException

getLogWriter

Specified by:
getLogWriter in interface CommonDataSource
Returns:
a PrintWriter object.
Throws:
SQLException - if any.

setLogWriter

public void setLogWriter(PrintWriter out)
                  throws SQLException

Specified by:
setLogWriter in interface CommonDataSource
Throws:
SQLException

setLoginTimeout

public void setLoginTimeout(int seconds)
                     throws SQLException

Specified by:
setLoginTimeout in interface CommonDataSource
Throws:
SQLException

getLoginTimeout

public int getLoginTimeout()
                    throws SQLException

getLoginTimeout

Specified by:
getLoginTimeout in interface CommonDataSource
Returns:
a int.
Throws:
SQLException - if any.

close

public void close()
           throws SQLException

close

Specified by:
close in interface ClosableDataSource
Throws:
SQLException - if any.

unwrap

public <T> T unwrap(Class<T> iface)
         throws SQLException

unwrap

Specified by:
unwrap in interface Wrapper
Type Parameters:
T - a T object.
Parameters:
iface - a Class object.
Returns:
a T object.
Throws:
SQLException - if any.

isWrapperFor

public boolean isWrapperFor(Class<?> iface)
                     throws SQLException

isWrapperFor

Specified by:
isWrapperFor in interface Wrapper
Parameters:
iface - a Class object.
Returns:
a boolean.
Throws:
SQLException - if any.


Copyright © 2011. All Rights Reserved.