Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

201.

What's The Jdbc 3.0 Api?

Answer»

The JDBC 3.0 API is the latest update of the JDBC API. It CONTAINS MANY features, including scrollable result sets and the SQL:1999 DATA types.

JDBC (Java Database Connectivity) is the standard for communication between a Java application and a relational database. The JDBC API is released in two versions; JDBC version 1.22 (released with JDK 1.1.X in package java.sql) and version 2.0 (released with Java platform 2 in packages java.sql and javax.sql). It is a SIMPLE and powerful largely database-independent way of extracting and INSERTING data to or from any database.

The JDBC 3.0 API is the latest update of the JDBC API. It contains many features, including scrollable result sets and the SQL:1999 data types.

JDBC (Java Database Connectivity) is the standard for communication between a Java application and a relational database. The JDBC API is released in two versions; JDBC version 1.22 (released with JDK 1.1.X in package java.sql) and version 2.0 (released with Java platform 2 in packages java.sql and javax.sql). It is a simple and powerful largely database-independent way of extracting and inserting data to or from any database.

202.

What Is Connection Pooling? What Is The Main Advantage Of Using Connection Pooling?

Answer»

A connection POOL is a mechanism to REUSE connections created. Connection pooling can increase performance dramatically by REUSING connections rather than creating a new PHYSICAL connection each time a connection is REQUESTED.

A connection pool is a mechanism to reuse connections created. Connection pooling can increase performance dramatically by reusing connections rather than creating a new physical connection each time a connection is requested.

203.

What Is A Datasource?

Answer»

A DATASOURCE object is the REPRESENTATION of a data SOURCE in the Java programming language. In basic terms,

  • A DataSource is a facility for storing data.
  • DataSource can be referenced by JNDI.
  • Data Source may point to RDBMS, file System , any DBMS ETC..

A DataSource object is the representation of a data source in the Java programming language. In basic terms,

204.

What Is The Need Of Batchupdates?

Answer»

The BatchUpdates feature allows US to group SQL statements together and send to database SERVER in one SINGLE TRIP.

The BatchUpdates feature allows us to group SQL statements together and send to database server in one single trip.

205.

What Are The Different Types Of Rowset ?

Answer»

There are two types of RowSet are there. They are:

  • Connected - A connected RowSet OBJECT CONNECTS to the database once and remains connected until the application terminates.
  • DISCONNECTED - A disconnected RowSet object connects to the database, executes a query to retrieve the data from the database and then closes the CONNECTION. A program may change the data in a disconnected RowSet while it is disconnected. Modified data can be updated in the database after a disconnected RowSet reestablishes the connection with the database.

There are two types of RowSet are there. They are:

206.

What Is Rowset?

Answer»

A RowSet is an object that encapsulates a set of rows from either Java Database Connectivity (JDBC) result sets or tabular DATA sources like a file or spreadsheet. RowSets support component-based DEVELOPMENT models like JavaBeans, with a STANDARD set of properties and an EVENT notification .

A RowSet is an object that encapsulates a set of rows from either Java Database Connectivity (JDBC) result sets or tabular data sources like a file or spreadsheet. RowSets support component-based development models like JavaBeans, with a standard set of properties and an event notification .

207.

What Is Resultset ?

Answer»

The ResultSet REPRESENTS set of rows RETRIEVED due to QUERY execution.

ResultSet rs = stmt.executeQuery(SQLQUERY);

The ResultSet represents set of rows retrieved due to query execution.

208.

What Are The Standard Isolation Levels Defined By Jdbc?

Answer»

The VALUES are DEFINED in the CLASS java.sql.Connection and are:

  • TRANSACTION_NONE
  • TRANSACTION_READ_COMMITTED
  • TRANSACTION_READ_UNCOMMITTED
  • TRANSACTION_REPEATABLE_READ
  • TRANSACTION_SERIALIZABLE

Any GIVEN database may not support all of these levels.

The values are defined in the class java.sql.Connection and are:

Any given database may not support all of these levels.

209.

Which Is The Right Type Of Driver To Use And When?

Answer»
  • TYPE I driver is handy for prototyping.
  • Type III driver ADDS security, caching, and connection CONTROL.
  • Type III and Type IV drivers need no pre-installation.

210.

Which Type Of Jdbc Driver Is The Fastest One?

Answer»

JDBC Net pure Java driver(Type IV) is the FASTEST driver because it converts the JDBC calls into vendor SPECIFIC protocol calls and it DIRECTLY interacts with the database.

JDBC Net pure Java driver(Type IV) is the fastest driver because it converts the JDBC calls into vendor specific protocol calls and it directly interacts with the database.

211.

What Are Types Of Jdbc Drivers?

Answer»

There are four types of drivers defined by JDBC as follows:

  • Type 1: JDBC/ODBC—These require an ODBC (Open Database Connectivity) driver for the database to be installed. This type of driver works by translating the submitted QUERIES into equivalent ODBC queries and forwards them via native API calls DIRECTLY to the ODBC driver. It provides no host redirection capability.
  • Type2: Native API (partly-JAVA driver)—This type of driver USES a vendor-specific driver or database API to interact with the database. An example of such an API is Oracle OCI (Oracle Call Interface). It also provides no host redirection.
  • Type 3: Open Protocol-Net—This is not vendor specific and works by forwarding database requests to a remote database source using a net server component. How the net server component accesses the database is transparent to the client. The client driver communicates with the net server using a database-independent protocol and the net server translates this protocol into database calls. This type of driver can access any database.
  • Type 4: Proprietary Protocol-Net(pure Java driver)—This has a same configuration as a type 3 driver but uses a wire protocol specific to a particular vendor and hence can access only that vendor's database. Again this is all transparent to the client.

 

There are four types of drivers defined by JDBC as follows:

 

212.

How To Call A Stored Procedure From Jdbc ?

Answer»

PL/SQL stored procedures are CALLED from within JDBC programs by means of the prepareCall() method of the Connection object created. A call to this method takes variable bind PARAMETERS as INPUT parameters as well as output variables and creates an object instance of the CALLABLESTATEMENT class. The following line of CODE illustrates this:

CallableStatement stproc_stmt = conn.prepareCall("{call procname(?,?,?)}");

Here conn is an instance of the Connection class.

 

PL/SQL stored procedures are called from within JDBC programs by means of the prepareCall() method of the Connection object created. A call to this method takes variable bind parameters as input parameters as well as output variables and creates an object instance of the CallableStatement class. The following line of code illustrates this:

Here conn is an instance of the Connection class.

 

213.

What Are Callable Statements ?

Answer»

Callable statements are used from JDBC application to INVOKE STORED procedures and FUNCTIONS.

Callable statements are used from JDBC application to invoke stored procedures and functions.

214.

What Is Preparedstatement?

Answer»

A prepared statement is an SQL statement that is precompiled by the database. Through precompilation, prepared statements improve the performance of SQL commands that are executed multiple times (given that the database supports prepared statements). Once COMPILED, prepared statements can be customized prior to each execution by altering predefined SQL PARAMETERS.

PreparedStatement pstmt = conn.prepareStatement("UPDATE EMPLOYEES SET SALARY = ? WHERE ID = ?");
pstmt.setBigDecimal(1, 153833.00);
pstmt.setInt(2, 110592);

Here: conn is an instance of the Connection class and "?" represents parameters.These parameters must be SPECIFIED before execution.

A prepared statement is an SQL statement that is precompiled by the database. Through precompilation, prepared statements improve the performance of SQL commands that are executed multiple times (given that the database supports prepared statements). Once compiled, prepared statements can be customized prior to each execution by altering predefined SQL parameters.

Here: conn is an instance of the Connection class and "?" represents parameters.These parameters must be specified before execution.

215.

What Is Statement ?

Answer»
  • STATEMENT acts like a VEHICLE through which SQL commands can be sent. Through the connection OBJECT we CREATE statement kind of objects.
  • Through the connection object we create statement kind of objects.
  • Statement stmt = conn.createStatement();
  • This method returns object which IMPLEMENTS statement interface.

216.

What Does The Connection Object Represents?

Answer»

The CONNECTION OBJECT represents communication context, i.e., all communication with DATABASE is through connection object only.

The connection object represents communication context, i.e., all communication with database is through connection object only.

217.

What Is Jdbc Driver Interface?

Answer»

The JDBC Driver INTERFACE PROVIDES vendor-specific implementations of the abstract classes provided by the JDBC API. Each vendor driver MUST provide implementations of the java.sql.Connection, STATEMENT, PREPARED Statement, CallableStatement, ResultSet and Driver.

The JDBC Driver interface provides vendor-specific implementations of the abstract classes provided by the JDBC API. Each vendor driver must provide implementations of the java.sql.Connection, Statement, Prepared Statement, CallableStatement, ResultSet and Driver.

218.

What Are The Main Components Of Jdbc ?

Answer»

The life cycle of a servlet CONSISTS of the following PHASES:

  • DriverManager: Manages a list of database drivers. Matches connection requests from the java application with the proper database DRIVER using communication subprotocol. The first driver that recognizes a certain subprotocol under JDBC will be used to establish a database Connection.
  • Driver: The database communications link, handling all communication with the database. Normally, once the driver is loaded, the developer need not call it explicitly.
  • Connection : Interface with all methods for contacting a database.The connection OBJECT represents communication context, i.e., all communication with database is through connection object only.
  • Statement : Encapsulates an SQL statement which is PASSED to the database to be parsed, compiled, planned and executed.
  • ResultSet: The ResultSet represents set of rows retrieved due to query execution.

The life cycle of a servlet consists of the following phases:

219.

Explain Basic Steps In Writing A Java Program Using Jdbc?

Answer»

JDBC makes the interaction with RDBMS simple and intuitive. When a Java application NEEDS to access DATABASE :

  • LOAD the RDBMS specific JDBC driver because this driver actually communicates with the database (INCASE of JDBC 4.0 this is automatically loaded).
  • Open the connection to database which is then used to send SQL statements and get results back.
  • Create JDBC Statement object. This object contains SQL query.
  • Execute statement which RETURNS resultset(s). ResultSet contains the tuples of database table as a result of SQL query.
  • Process the result set.
  • Close the connection.

JDBC makes the interaction with RDBMS simple and intuitive. When a Java application needs to access database :

220.

What Are The New Features Added To Jdbc 4.0?

Answer»

The major features added in JDBC 4.0 INCLUDE :

  • Auto-loading of JDBC driver class
  • Connection MANAGEMENT enhancements
  • Support for ROWID SQL TYPE
  • DataSet implementation of SQL using Annotations
  • SQL exception handling enhancements
  • SQL XML support

The major features added in JDBC 4.0 include :

221.

What Is The Jdbc?

Answer»

Java Database Connectivity (JDBC) is a STANDARD Java API to interact with relational databases FORM Java. JDBC has set of classes and interfaces which can use from Java application and talk to database without learning RDBMS details and USING Database Specific JDBC DRIVERS.

Java Database Connectivity (JDBC) is a standard Java API to interact with relational databases form Java. JDBC has set of classes and interfaces which can use from Java application and talk to database without learning RDBMS details and using Database Specific JDBC Drivers.