Class DatabaseUtil
- java.lang.Object
-
- org.pentaho.di.core.database.util.DatabaseUtil
-
- All Implemented Interfaces:
DataSourceProviderInterface
public class DatabaseUtil extends Object implements DataSourceProviderInterface
Provides default implementation for looking data sources up in JNDI.- Author:
- mbatchel
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.pentaho.di.core.database.DataSourceProviderInterface
DataSourceProviderInterface.DatasourceType
-
-
Constructor Summary
Constructors Constructor Description DatabaseUtil()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static voidclearDSCache()Clears cache of DataSources (For Unit test)static voidcloseSilently(Connection conn)static voidcloseSilently(Connection[] connections)static voidcloseSilently(Statement st)static voidcloseSilently(Statement[] statements)protected static DataSourcegetDataSourceFromJndi(String dsName, Context ctx)Since JNDI is supported different ways in different app servers, it's nearly impossible to have a ubiquitous way to look up a datasource.DataSourcegetNamedDataSource(String datasourceName)Implementation of DatasourceProviderInterface.DataSourcegetNamedDataSource(String datasourceName, DataSourceProviderInterface.DatasourceType type)Returns the named data source of respecting itstypeDataSourceinvalidateNamedDataSource(String datasourceName, DataSourceProviderInterface.DatasourceType type)Invalidate the named data source of respecting itstype-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.pentaho.di.core.database.DataSourceProviderInterface
getPooledDataSourceFromMeta
-
-
-
-
Method Detail
-
clearDSCache
protected static void clearDSCache()
Clears cache of DataSources (For Unit test)
-
getDataSourceFromJndi
protected static DataSource getDataSourceFromJndi(String dsName, Context ctx) throws NamingException
Since JNDI is supported different ways in different app servers, it's nearly impossible to have a ubiquitous way to look up a datasource. This method is intended to hide all the lookups that may be required to find a jndi name.- Parameters:
dsName- The Datasource name- Returns:
- DataSource if there is one bound in JNDI
- Throws:
NamingException
-
closeSilently
public static void closeSilently(Connection[] connections)
-
closeSilently
public static void closeSilently(Connection conn)
-
closeSilently
public static void closeSilently(Statement[] statements)
-
closeSilently
public static void closeSilently(Statement st)
-
getNamedDataSource
public DataSource getNamedDataSource(String datasourceName) throws DataSourceNamingException
Implementation of DatasourceProviderInterface.- Specified by:
getNamedDataSourcein interfaceDataSourceProviderInterface- Returns:
- javax.sql.DataSource
- Throws:
DataSourceNamingException
-
getNamedDataSource
public DataSource getNamedDataSource(String datasourceName, DataSourceProviderInterface.DatasourceType type) throws DataSourceNamingException
Description copied from interface:DataSourceProviderInterfaceReturns the named data source of respecting itstype- Specified by:
getNamedDataSourcein interfaceDataSourceProviderInterface- Parameters:
datasourceName- name of the desired data sourcetype- data source's type- Returns:
- named data source
- Throws:
DataSourceNamingException
-
invalidateNamedDataSource
public DataSource invalidateNamedDataSource(String datasourceName, DataSourceProviderInterface.DatasourceType type) throws DataSourceNamingException
Description copied from interface:DataSourceProviderInterfaceInvalidate the named data source of respecting itstype- Specified by:
invalidateNamedDataSourcein interfaceDataSourceProviderInterface- Parameters:
datasourceName- name of the desired data sourcetype- data source's type- Returns:
- named data source
- Throws:
DataSourceNamingException
-
-