When using enterprise Java applications, it is not considered good to instantiate database connections manually. The more standard method involves using a database connection pool in the form of a JDBC data source, which is provided by your application server (Tomcat, Jetty, WebLogic). The application server is responsible for maintaining a number of connections to the database service, and the code locates the data source through JNDI to obtain a connection.
In some instances, however, you want to be able to manage and maintain the efficiency and centralization of the database connection pool. Consider the following scenarios:
- Your application runs in a managed environment and you don't have access to the application server's administrative console. This is common in the corporate environment, as well as with some Web hosts.
- You want a container-neutral Web application that can be deployed by third parties with minimal intervention on your part.
- Your application runs in a special environment, such as a demo CD-ROM, that requires it to be even more self-contained than a standard Web application.
Configuring Platform to Use Pentaho-Managed Data Sources
The Pentaho BI Platform uses Pooled + JNDI data sources by default.
If you decide to not use the Pentaho-managed data sources (the data sources that are created through the Pentaho Admin Console) you can use either NonPooledDatasource Service or NonPooledOrJndiDatasourceService.
This datasource service retrieve the datasource objects from a connection pool already setup during the server startup. If it encounters a new datasource being requested, it will read the meta data and add the datasource to the connection pool. You will not be able to use any JNDI connection with this service
This datasource service retrieves the datasource meta data from the database and construct the datasource object for you. It stores these datasource info in the cache for it to be used for the next time. You will not be able to use any JNDI connection with this service
If you desire to use pooled and jndi connection togather, you will need to use this service. When the request is made for a datasource connection, it first finds in the pooled connection and if the datasource is not available it searches with the default JNDI provider for that datasource. If the datasource have the same name in pooled and jndi, the pooled one will take precidence.
If you desire to use non pooled and jndi connection togather, you will need to use this service. When the request is made for a datasource connection, it first finds in the cache for the datasource and if the datasource is not available it searches with the default JNDI provider for that datasource.If the datasource have the same name in pooled and jndi, the pooled one will take precidence.
If applicable, change these configuration by modifying the pentahoObject.spring.xml in the pentaho-solutions/system folder.
You must also include a version of DatasourceSystemListener. For connection pooling solution use the PooledDatasourceSystemListener. For the regular, non-pooling option use NonPooledDatasourceSystemListener. The listeners are plugged through the systemListeners.spring.xml in the pentaho-solutions/system folder.
This listener reads the data source metadata from the database and setup connection pools and stores this information in a cache.
This listener* listener loads the database metadata into the cache. If the cache manager is not available,it will use a simple map implementation of ICacheManager.