Wednesday, June 25, 2014

WebLogic JDBC Interview Questions



(1) What is JDBC?
Java Database Connectivity is a Java API which is used for accessing the database

(2) What is a data source?
A JDBC data source is an object bound to the JNDI tree that provides database connectivity through a pool of JDBC connections

(3) What is a connection pool?
Connection pool is a group of connections which are used to create physical database connections

(4) What are the advantages of connection pool?
  • It provides re-usability of database connections
  • It provides Readily Available Connections
  • You can test the connection (Test Connection on Reserve) before giving it to an application
  • No hard coding is required. You can change host name, service name, port etc., in WebLogic Admin Console 

(5) When JDBC Connections are created?
  • When starting up WebLogic Server 
  • When deploying the connection pool to a target server or cluster 

(6) What are the different types of WebLogic Server JDBC Data Sources?
  • Generic Data Sources
  • Multi Data Sources
  • Grid Link Data Sources

(7) What is a Generic Data Source?
It provides database connectivity through a pool of JDBC connections

(8) What is Multi Data Source?
Multi Data Source is an abstraction around group of databases which provides either load balancing or fail-over

(9) What is a Grid Link Data Source?
Grid Link  Data Source is a data source which provides connectivity between WebLogic Server and an Oracle RAC (Real Application Cluster) Database. The Grid Link Data Source is introduced from WebLogic Server 10.3.4.

(10) What are the algorithms supported by Multi Data Source?
  • Load Balancing
  • Fail-over
(11) What will happen to in-use connections if one of the data source in Multi Data source fails?
The Multi data source does not provide fail-over for active and in-use connections.

(12) What are the advantages of GridLink data source?
GridLink Data Source provides:
  • Fast Connection Fail-over
  • Runtime Connection Load Balancing 
  • GridLink Affinity

13) What is FAN?
FAN stands for Fast Application Notification events. Enabling FAN Events allows a data source to subscribe to and process Oracle Fast Application Notification (FAN) events.

(14) What is ONS?
Oracle Notification Service (ONS) is used to adaptively respond to state changes in an Oracle RAC instance.  ONS Client will connect to a list of ONS daemon listen addresses and port for receiving ONS-based FAN events.

You can enable FAN Events by
  • Select Fan Enabled
  • Provide a comma-separate list of ONS daemon listen addresses and ports for receiving ONS-based FAN events. You can use Single Client Access Name (SCAN) addresses to access FAN notifications.


(15) What is the default database listen port?
1521

(16) What is the default ONS listen port?
6200

(17) What is JDBC URL?
It is the URL of the database to connect to. Data base locations are specified using a JDBC Uniform Resource Locator (URL). The format of the URL varies by JDBC driver.

Examples for JDBC URL:
jdbc:oracle:thin:@<database host>:<db listener port>/<database service name>


(18) What are the different types of JDBC Drivers?
  • Type 1 Driver ( JDBC-ODBC Driver)
  • Type 2 Driver ( Native Driver)
  • Type 3 Driver ( Network Driver)
  • Type 4 Driver (Pure Java Driver)

(19) What are the databases supported by Oracle WebLogic?
  • Orace Database
  • Sybase
  • MySQL
  • DB2
  • Pointbase
  • Microsoft SQL Server etc  (for more information refer the oracle documentation)

(20) What is the difference between XA driver & Non-XA driver?
 XA stands for eXtended Architecture, which is used to support Global Transactions.
Non-XA stands for non-eXtended Architecture which is used to support Location Transactions
 
(21) What is the difference between Local transactions & Global transactions?

A transaction which involves single database is known as local transaction.
A transaction which involves multiple databases is known as Global transaction.
 
(22) What is LLR?
 
(23) Which JNDI name is used in  applications in case of Multi Data Source?

You need to use the JNDI name that you have used while creating a multi data source in WebLogic
 
(24) Total number of JDBC connections?

(25) What is data source targeting & un-targeting?
You can select one or more targets to deploy your new JDBC data source. If you don't select a target, the data source will be created but not deployed. You will need to deploy the data source at a later time. Un-targeting a datasource is deselection the data source targets

(26) What is oracle.net.CONNECT_TIMEOUT?
The property oracle.net.CONNECT_TIMEOUT helps to set the login time out in Oracle.
 
(27) What is oracle.jdbc.ReadTimeout ?

The property oracle.jdbc.ReadTimeout helps to set read timeout while reading from the socket.

(28) What is the difference between thin driver & thick driver?

(29)  What is Test Connections On Reserve?
It enables WebLogic Server to test a connection before giving it to a client. (It requires that you specify a Test Table Name)

(30) What is Test Frequency?
It is the number of seconds a WebLogic Server instance waits between attempts when testing unused connections.(It requires that you specify a Test Table Name.) Connections that fail the test are closed and reopened to re-establish a valid physical connection. If the test fails again, the connection will be closed

(31) What is Shrink Frequency?  
The number of seconds to wait before shrinking a connection pool that has incrementally increased to meet demand. Default value 900 seconds(15mins)

(32) What is Inactive Connection Timeout?
The number of inactive seconds on a reserved connection before WebLogic Server reclaims the connection and releases it back into the connection pool. If you set the Inactive Connection Timeout feature to a positive value, the WebLogic server reclaims the leaked connections

(33) What happen if you select the "Fan Enabled" during Grid Link data source creation?  
It enables the data source to subscribe to and process Oracle FAN events.

(34) What is the use of ONS nodes?
A comma-separate list of ONS daemon listen addresses and ports to which connect to for receiving ONS-based FAN events.
Example: <ONS Scan Address>:6200 or <ONSHOST1>:6200,<ONSHOST2>:6200

(35) What is the use of Profile Connection Leak?
This is used to collect profile information about threads that have reserved a connection from the data source and the connection leaked (was not properly returned to the pool of connections).
Set the Inactive Connection Timeout feature to a positive value to reclaim leaked connection.

(36) What are different data source control operations that you can perform?
  • Shrink
  • Reset
  • Clear Statement Cache
  • Suspend
  • Resume
  • Shutdown
  • Resume

(37) What is the use of Capacity Increment Attribute?
WebLogic first uses the existing connections available in the pool when a connection request is issued. If there are no connections available, this parameter takes care of creating a new connection.
In WebLogic Server 10.3.1 and higher releases, the Capacity Increment attribute is no longer configurable and is set to a value of 1.


(38) Difference between MinCapacity & InitialCapacity?
The MinCapacity attribute sets the minimum number of physical connections that a connection pool can contain after it is initialized.
The Minimum Capacity parameter was added in WebLogic Server 10.3.6.
The InitialCapacity value that previously handled both the initial and minimum capacity for the pool this has been split into two attributes:
  • MinCapacity defaults to InitialCapacity if not set; InitialCapacity continues to default to 1.
  • MinCapacity is only used for shrinking calculations only. It is lazy in that the minimum connections are not created when the server starts up; InitialCapacity is used for this function.
  • For upward compatibility, InitialCapacity is used if MinCapacity is not set.

(39) What will you do if the database is down during WebLogic Servers start-up? 
If a data source connection cannot be established with the database during startup for some reason, the Managed Server starts in the ADMIN state instead of in the RUNNING state. The commonly used procedure in this situation is to click on the Resume button; the server instance resumes to the RUNNING state and starts accepting and processing the application requests.


But errors will occur with the applications that use this data source. Even if the database goes back online, the data source will not start automatically. Then you need to perform un-targeting and targeting of data source



(40) What will you do to avoid the ADMIN state on start-up when there is  a database issue?
To avoid the ADMIN state on start-up, set the data source Initial Capacity to 0 so it won't open any connection to the database  during the server startup process. The Managed Server instance will start in the RUNNING state, and as soon as the database  goes back online, the data source will reconnect to it without intervention.


(41) What is the use of Thin JDBC Driver?



Note:
  • The Multi data source is responsible for managing the load and failover; so if the Oracle database uses the SCAN address feature, it's recommended to set up a Grid Link data source instead.
  • In WebLogic Server 12c,  for production environments it would be to set Initial Capacity to 0 and Minimum Capacity and Maximum Capacity to the same value.
  • During the WebLogic Server start up process, the data sources are deployed and the connections to the databases are opened according to the Initial Capacity parameter.