Class DataSourceConnectionProvider
×News: XavaPro 7.7 released - March 11 · Read more
java.lang.Object
org.openxava.util.DataSourceConnectionProvider
- All Implemented Interfaces:
Serializable, IConnectionProvider
public class DataSourceConnectionProvider
extends Object
implements IConnectionProvider, Serializable
Adapter from JNDI DataSource interface to IConnectionProvider interface.
- Author:
- Javier Paniza
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic IConnectionProvidercreateByComponent(String componentName) static IConnectionProvidergetByComponent(String componentName) Returns a JDBC connection by default.getConnection(String dataSourceName) Returns a JDBC connection from a identifier.DataSource to wrapJNDI of DataSource to wrap.getUser()static booleanIftruethen all intances use hibernate connection for obtain connection, instead of data source connection pool.voidsetDataSourceJNDI(String dataSourceJDNI) JNDI of DataSource to wrap.voidsetDefaultDataSource(String dataSourceName) Sets the datasource name used when usingIConnectionProvider.getConnection().voidsetPassword(String password) Sets password used to create connection.static voidsetUseHibernateConnection(boolean useHibernateConnection) Iftruethen all intances use hibernate connection for obtain connection, instead of data source connection pool.voidSets the user used to craete the connection.
-
Constructor Details
-
DataSourceConnectionProvider
public DataSourceConnectionProvider()
-
-
Method Details
-
createByComponent
- Throws:
XavaException
-
getByComponent
- Throws:
XavaException
-
getDataSource
-
getDataSourceJNDI
JNDI of DataSource to wrap.Only works if datasource == null
-
setDataSourceJNDI
JNDI of DataSource to wrap.Only works if datasource == null
-
getConnection
Description copied from interface:IConnectionProviderReturns a JDBC connection by default.- Specified by:
getConnectionin interfaceIConnectionProvider- Throws:
SQLException- If there are problem obtaining the connetion
-
getConnection
Description copied from interface:IConnectionProviderReturns a JDBC connection from a identifier.- Specified by:
getConnectionin interfaceIConnectionProvider- Parameters:
dataSourceName- Name of data source from what I obtain the connection- Throws:
SQLException- If there are problem obtaining the connetion
-
setPassword
Description copied from interface:IConnectionProviderSets password used to create connection.* Must to call to
IConnectionProvider.setUser(String)too. Although set user and password is not mandatory.- Specified by:
setPasswordin interfaceIConnectionProvider
-
setUser
Description copied from interface:IConnectionProviderSets the user used to craete the connection.It is not mandatory to call this method.
- Specified by:
setUserin interfaceIConnectionProvider
-
getPassword
-
getUser
-
setDefaultDataSource
Description copied from interface:IConnectionProviderSets the datasource name used when usingIConnectionProvider.getConnection().- Specified by:
setDefaultDataSourcein interfaceIConnectionProvider
-
isUseHibernateConnection
public static boolean isUseHibernateConnection()Iftruethen 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.
-
setUseHibernateConnection
public static void setUseHibernateConnection(boolean useHibernateConnection) Iftruethen 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.
-