• +91 9723535972
  • info@interviewmaterial.com

JDBC Interview Questions and Answers

JDBC Interview Questions and Answers

Question - 91 : - Explain JDBC Savepoint?

Answer - 91 : -

A savepoint represents a point that the current transaction can roll back to. Instead of rolling all its changes back, it can choose to roll back only some of them.

Question - 92 : - List the advantages of using DataSource?

Answer - 92 : -

Data source is dividing work among administrator and programmer/developer.

The administrator creates a DataSource object and ties up it with JNDI registry. A programmer/ developer retrieves the DataSource object from the registry.  Then it will establish the connection with the database.

Question - 93 : - What is the reason why we need a JdbcRowSet like the wrapper around ResultSet?

Answer - 93 : -

We can use ResultSet object as a JavaBeans component.

  • A JdbcRowSet also can be used as a JavaBeans component. That’s why it can be created and configured at design or compile time and executed at run time.
  • All jdbcRowSet objects are scrollable and updatable.

Question - 94 : - How many ways that we can view a result set?

Answer - 94 : -

There are 2 ways to view ResultSet

  • column
  • column index.
Example: getInt(String columnName), getInt(int columnIndex)

Question - 95 : - How many ways can you update a result set?

Answer - 95 : -

Following methods helps you to update result set

  • updateRow()
  • deleteRow()
  • refreshRow()
  • cancelRowUpdates()
  • insertRow()

Question - 96 : - Why should we close database connections in Java?

Answer - 96 : -

As a best practice, we must close the resultset, the statement and the connection. If the connection is coming from a pool, on closure, the connection is sent back to the pool for reuse. We are doing this in the finally{} block, because if any exception occurs, then we still get the chance to close this.

Question - 97 : - Why are we using blob datatypes in JDBC?

Answer - 97 : -

These are used to store a large amount of data into the database like images, movie, etc.

Question - 98 : - How to set the attribute Concurrency in ResultSet?

Answer - 98 : -

There are two concurrency levels

  • CONCUR_READ_ONLY – It is only for reading.
  • CONCUR_UPDATABLE − It is for both read and updated.

Question - 99 : - How to call Stored Procedures in JDBC?

Answer - 99 : - We can execute the SQL Stored procedures through the CallableStatement interface. The CallableStatement object can be created using the prepareCall() method of the Connection interface.

Question - 100 : - What is the ResultSet interface?

Answer - 100 : -

ResultSet interface is used to store the output data after the SQL query execution. The object of ResultSet maintains the cursor point at the result data. As a default, the cursor points before the first row of the result data. We can traverse the data in the resultset objects as well.

Syntax:

Statement Interface:

Statement stmnt1 = conn.createStatement();
 
ResultSet resultset = stmnt1.executeQuery(“Select * from EMPLOYEE”);
PreparedStatement Interface:

PreparedStatement pstmnt1 = conn.prepareStatement(insert_query);
 
ResultSet resultset = pstmnt1.executeQuery(“Select * from EMPLOYEE”);


NCERT Solutions

 

Share your email for latest updates

Name:
Email:

Our partners