JNDI — Java Naming and Directory Interface API is naming service which enables components to locate other components and resources.
JDBC — Java Database Connectivity API, used to execute common SQL statements and perform other objectives common to database applications.
Application Servers usually have a JNDI Context for sharing global objects among different applications.
JNDI Interface to get instances of local/remote resources.
In a JNDI directory you’re actually storing a JDBC DataSource, so, you’re simply using JDBC to obtain a Connection via JNDI lookup.
You access this context via names, obtaining stored objects and share global objects among different applications.
javax.sql.DataSource is a factory for getting connections to different physical data sources. javax.sql.DataSource interface is registered with the naming service based on JNDI API. A data source driver allows accessed to the database via DataSource interface. A DataSource object is looked up in the context based on registered through JNDI Resource. The connection to the data source, such as database is attempted when javax.sql.DataSource‘s getConnection() method is called.
Database Connection pooling increase performance and reduced connection creation and removal overhead due to connection reuse by the connection pool.
Configure connection pool for better performance :
o For applications that consistently involve heavy database traffic:
Determine the optimal Maximum Capacity of a data source experimentally
Set the lnitial Capacity and Maximum Capacity to the same value.
o For applications, where peak database load is intermittent:
Use different values for initial and maximum sizes.
Tune Capacity increment and Shrink Frequency on the basis of load changes.