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 void
clearDSCache()
Clears cache of DataSources (For Unit test)static void
closeSilently(Connection conn)
static void
closeSilently(Connection[] connections)
static void
closeSilently(Statement st)
static void
closeSilently(Statement[] statements)
protected static DataSource
getDataSourceFromJndi(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.DataSource
getNamedDataSource(String datasourceName)
Implementation of DatasourceProviderInterface.DataSource
getNamedDataSource(String datasourceName, DataSourceProviderInterface.DatasourceType type)
Returns the named data source of respecting itstype
DataSource
invalidateNamedDataSource(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:
getNamedDataSource
in interfaceDataSourceProviderInterface
- Returns:
- javax.sql.DataSource
- Throws:
DataSourceNamingException
-
getNamedDataSource
public DataSource getNamedDataSource(String datasourceName, DataSourceProviderInterface.DatasourceType type) throws DataSourceNamingException
Description copied from interface:DataSourceProviderInterface
Returns the named data source of respecting itstype
- Specified by:
getNamedDataSource
in 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:DataSourceProviderInterface
Invalidate the named data source of respecting itstype
- Specified by:
invalidateNamedDataSource
in interfaceDataSourceProviderInterface
- Parameters:
datasourceName
- name of the desired data sourcetype
- data source's type- Returns:
- named data source
- Throws:
DataSourceNamingException
-
-