public class DataSourceConnectionProvider extends java.lang.Object implements IConnectionProvider, java.io.Serializable
Constructor and Description |
---|
DataSourceConnectionProvider() |
Modifier and Type | Method and Description |
---|---|
static IConnectionProvider |
createByComponent(java.lang.String componentName) |
static IConnectionProvider |
getByComponent(java.lang.String componentName) |
java.sql.Connection |
getConnection()
Returns a JDBC connection by default.
|
java.sql.Connection |
getConnection(java.lang.String dataSourceName)
Returns a JDBC connection from a identifier.
|
javax.sql.DataSource |
getDataSource()
DataSource to wrap
|
java.lang.String |
getDataSourceJNDI()
JNDI of DataSource to wrap.
|
java.lang.String |
getPassword() |
java.lang.String |
getUser() |
static boolean |
isUseHibernateConnection()
If
true then all intances use hibernate connection for obtain
connection, instead of data source connection pool. |
void |
setDataSourceJNDI(java.lang.String dataSourceJDNI)
JNDI of DataSource to wrap.
|
void |
setDefaultDataSource(java.lang.String dataSourceName)
Sets the datasource name used when using
IConnectionProvider.getConnection() . |
void |
setPassword(java.lang.String password)
Sets password used to create connection.
|
static void |
setUseHibernateConnection(boolean useHibernateConnection)
If
true then all intances use hibernate connection for obtain
connection, instead of data source connection pool. |
void |
setUser(java.lang.String user)
Sets the user used to craete the connection.
|
public static IConnectionProvider createByComponent(java.lang.String componentName) throws XavaException
XavaException
public static IConnectionProvider getByComponent(java.lang.String componentName) throws XavaException
XavaException
public javax.sql.DataSource getDataSource() throws javax.naming.NamingException
javax.naming.NamingException
public java.lang.String getDataSourceJNDI()
Only works if datasource == null
public void setDataSourceJNDI(java.lang.String dataSourceJDNI)
Only works if datasource == null
public java.sql.Connection getConnection() throws java.sql.SQLException
IConnectionProvider
getConnection
in interface IConnectionProvider
java.sql.SQLException
- If there are problem obtaining the connetionpublic java.sql.Connection getConnection(java.lang.String dataSourceName) throws java.sql.SQLException
IConnectionProvider
getConnection
in interface IConnectionProvider
dataSourceName
- Name of data source from what I obtain the connectionjava.sql.SQLException
- If there are problem obtaining the connetionpublic void setPassword(java.lang.String password)
IConnectionProvider
*
Must to call to IConnectionProvider.setUser(java.lang.String)
too. Although set user and password
is not mandatory.
setPassword
in interface IConnectionProvider
public void setUser(java.lang.String user)
IConnectionProvider
It is not mandatory to call this method.
setUser
in interface IConnectionProvider
public java.lang.String getPassword()
public java.lang.String getUser()
public void setDefaultDataSource(java.lang.String dataSourceName)
IConnectionProvider
IConnectionProvider.getConnection()
. setDefaultDataSource
in interface IConnectionProvider
public static boolean isUseHibernateConnection()
true
then all intances use hibernate connection for obtain
connection, instead of data source connection pool. Useful for using outside an application server, for example, in a junit test.
public static void setUseHibernateConnection(boolean useHibernateConnection)
true
then all intances use hibernate connection for obtain
connection, instead of data source connection pool. Useful for using outside an application server, for example, in a junit test.