The javax.sql package defines extension to the JDBC 2.0 API to support connection pooling, data source, distributed transaction, and so on. DB2 universal database implements all of these interfaces. DataSource implementation is explained below.
Using DriverManager to get the database connection makes the application dependent on the vendor specific URL and driver classes. A DataSource object can be used to get the connection, which is portable among the different data sources, hence, not dependent on the specific URL format and driver classes.
This portability is gained by registering the different data sources with the JNDI service (javax.naming service) and getting the information about any data sources by providing the logical name of the datasource in the application. A DataSource object is either created in the application itself or by a lookup in the JNDI service. Before making use of lookup in JNDI services, you need to register the database to JNDI.
The Example gives an example of creating DataSource object by JNDI lookup service and getting the connection to the data source.
Creating DataSource by JNDI lookup service
A DataSource object can be bound to a logical name by registering it to JNDI. Registering to JNDI services requires setting all of the properties to get a connection such as database name, user name, password, and so on. Once the data source is registered, an application needs to know only the logical name to retrieve the database connection. DB2 universal driver provides the following implementation for the DataSource:com.ibm.db2.jcc.DB2SimpleDataSource
A data source can be registered using this implementation as shown in below
Registering data source
IBM DB2 Related Interview Questions
|IBM Websphere Interview Questions||IBM-REXX Interview Questions|
|IBM Cognos Interview Questions||IBM DB2 Interview Questions|
|J2EE Interview Questions||COBOL Interview Questions|
|IBM-JCL Interview Questions||DB2 Using SQL Interview Questions|
|IBM WAS Administration Interview Questions||IBM WebSphere Administration Interview Questions|
|Database Administration Interview Questions||DB2 SQL Programming Interview Questions|
|Mainframe DB2 Interview Questions|
IBM DB2 Related Practice Tests
|IBM Websphere Practice Tests||IBM Cognos Practice Tests|
|IBM DB2 Practice Tests||J2EE Practice Tests|
|COBOL Practice Tests||IBM-JCL Practice Tests|
|DB2 Using SQL Practice Tests||IBM WAS Administration Practice Tests|
|Database Administration Practice Tests||DB2 SQL Programming Practice Tests|
Ibm Db2 Tutorial
Db2 Application Development Overview
Application Development With Db2 Purexml
Application Development With Php
Application Development With C/c++
Application Development With Java
Application Development With .net
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.