• +91 9723535972
  • info@interviewmaterial.com

JDBC Interview Questions and Answers

JDBC Interview Questions and Answers

Question - 81 : - Why “No suitable driver” error occurs?

Answer - 81 : -

No suitable driver” occurs when we are calling DriverManager.getConnection method,

it may occur because of following reasons:

  • unable to load exact JDBC drivers before calling the getConnection method.
  • It may be invalid or wrong JDBC URL.

Question - 82 : - Prepared Statements are faster. Why?

Answer - 82 : -

Prepared statement execution is faster than direct execution because the statement is compiled only once. Prepared statements & JDBC driver are connected with each other during execution, and there are no connection overheads.

Question - 83 : - Is it possible to connect to multiple databases? Using single statement can we update or extract data from two or three or many databases?

Answer - 83 : -

Yes, it is possible to connect to multiple databases, at the same time, but it depends on the specific driver.

To update and extract data from the different database we can use the single statement. But we need middleware to deal with multiple databases or a single database.

Question - 84 : - What is the meaning of “dirty read” in the database?

Answer - 84 : -

Dirty read means “read the value which may be correct or may not be correct.”

Question - 85 : - What do you mean by two phase commits?

Answer - 85 : -

Two phase commit is used in distributed transaction process. If any transaction is executing and it will affect multiple databases. Two phase commits will be used to make all databases synchronized with each other.

Question - 86 : - How many locking systems are there in JDBC?

Answer - 86 : -

Two types of locking are available in JDBC by which we can handle more than one user.

If two users are viewing the same record, then no locking is done. If one user is updating a record and the second user is also updating the same record.  At that time, we are going to use locking.

  • Optimistic Locking: it will lock the record only when we are going to “update.”
  • Pessimistic Locking: it will lock the record from the “select” to view, update and commit time.

Question - 87 : - What are the exceptions in JDBC?

Answer - 87 : -

There are four types of exceptions in JDBC.

  • batchUpdate Exception
  • Data Truncation
  • SQL Exception
  • SQL Warning

Question - 88 : - What are the new features available in JDBC 4.0?

Answer - 88 : -

The new features are

  • Auto loading by JDBC driver class
  • Enhanced Connection Management
  • RowId SQL enabled
  • Dataset implemented by SQL by using Annotations
  • Enhancements of SQL exception handling
  • Supporting SQL XML files

Question - 89 : - How many RowSet are available in JDBC?

Answer - 89 : -

There are two types of row sets are available:

  • Connected – A connected RowSet object connects to the database instantaneously. If the application terminates then connected RowSet object also terminates.
  • Disconnected – A disconnected RowSet object connects to the database after execution of the required query.

Question - 90 : - What is the meaning of connection?

Answer - 90 : -

Connection interface consists of methods for interaction with the database.


NCERT Solutions

 

Share your email for latest updates

Name:
Email:

Our partners