Jdbc Interview Questions

Advertisements

Prev Tutorial Next Tutorial

Jdbc Interview Questions

jdbc interview questions

JDBC Interview Question for Freshers

What is Jdbc ?

JDBC (Java Database Connectivity) is uses for connect java application with database. It is Java SE technology, which is install automatically with the jdk software.

How many packages have Jdbc API ?

Jdbc API consists of two packages

  • java.sql package
  • javax.sql package

When you connect java appplication with database using Jdbc it's become database dependent ?

No, Jdbc ia an API (Application programming interface) used to communicate Java application to database in database independent and platform independent manner.

Difference between ODBC and JDBC

ODBCJDBC
1Odbc is platform dependent and database independent.Jdbc is both platform and database independent.
1Odbc implemented in C language with pointer.Jdbc implemented in java without pointer.

What is DSN (Data Source Name) ?

DSN (Data Source Name) is a file which stores a database name.

What is Jdbc Driver ?

Jdbc API contains a set of classes and Interfaces where classes definition is provided by Sun Micro System and Interfaces Implementation are not provided. For interface Implementation classes will be provided by vendors, these set of classes are called Jdbc Driver Software.

Explain types of Jdbc Driver ?

JDBC Driver is a software component that enables java application to communicate with the database.There are 4 types of JDBC drivers, they are:

  • Jdbc-Odbc Bridge Driver
  • Native-API driver (partially java driver)
  • Network Protocol driver (fully java driver)
  • Thin driver (fully java driver)

Why use Jdbc ?

In yearly days for communicate front end application to database, front end application used a set of function given by database vendor, to connect with a database.

Even today C and C++ application are connecting with oracle database using a set of function given by oracle corporation in a orcl.h header file.

But problem with the above communication is a front end application become as a database dependent application, because every database vendor give its own set of function for communication.

To overcome the database dependent problem ODBC (Open database connectivity) community formed by Microsoft with Simba technologies. ODBC community has provided ODBC API, to connect with any database in a database independent manner.

Why Odbc not use in Java Application ? ?

ODBC API is written in C language woth pointer but Java application does not contain pointer so internally non pointers java code is converted to C pointers code this conversion is a time consuming process so the connectivity is very slow.

Java application is platform independent but if it is combined with ODBC then it become platform dependent but this is against of java motto or principal. To solved the above problems Sum MicroSystem introduced JDBC technology. Jdbc technology makes java applications as platform independent and database independent.

In which formate image are store in database ?

In database images are store in binary form.

Difference between Scrollable ResultSet and Non-Scrollable ResultSet ?

Non-Scrollable ResultSetScrollable ResultSet
1Cursor move only in forward directionCursor can move both forward and backward direction
1Slow performance, If we want to move nth record then we need to n+1 iterationFast performance, directly move on any record.
1Non-Scrollable ResultSet cursor can not move randomlyScrollable ResultSet cursor can move randomly

Why use ResultSetMetaData ?

While executing a select operation on a database, if the table structure is already known for the programmer then a programmer of Jdbc can read the data from ResultSet object directly. If the strucure of table is unknown then need ResultSetMetaData.

Difference between PreparedStatement and Statement ?

StatementPreparedStatement
1Statement interface is slow because it compile the program for each executionPreparedStatement interface is faster, because its compile the command for once.
2We can not use ? symbol in sql command so setting dynamic value into the command is complexWe can use ? symbol in sql command, so setting dynamic value is simple.
3We can not use statement for writing or reading binary data (picture)We can use PreparedStatement for reading or writing binary data.

Difference between Statement and PreparedStatement ?

StatementPreparedStatement
1Statement interface is slow because it compile the program for each executionPreparedStatement interface is faster, because its compile the command for once.
2We can not use ? symbol in sql command so setting dynamic value into the command is complexWe can use ? symbol in sql command, so setting dynamic value is simple.
3We can not use statement for writing or reading binary data (picture)We can use PreparedStatement for reading or writing binary data.

What is Batch Processing ?

Instead of executing a single query, we can execute a batch (group) of queries using batch processing.

Why need of Batch Processing ?

In a Jdbc program if multiple sql operations are there, then each operation is individually transfer to the database. This approach will increase the number of round trips between java program (application) and database. If the number of round trips are increased between an application and database, then it will reduce the performance of an application. To overcome these problem we use Batch Processing.

What is main Advantage of Batch Processing ?

Increase the performance of an application.

What is Properties Files ?

A Property File is one type of the file which organizing the data in the form of (key, value) pair.

How to Insert Images in Database ?

you can not Insert a Picture in DataBase directly. but you can store binary data of picture file. To insert image in database we need a column of type BLOB (Binary Large Object).

How to Retrieve Images from Database ?

you can not Retrieve a Picture from DataBase directly. While retrieving a image from a database, the binary data of image will be selected from the database.


Prev Tutorial Next Tutorial

Google Advertisment

Buy This Ad Space @$20 per Month, Ad Size 600X200 Contact on: hitesh.xc@gmail.com or 9999595223

Magenet is best Adsense Alternative here we earn $2 for single link, Here we get links ads. Magenet

For Projects 9999595223

Google Advertisements


Buy Websites 9999595223

Buy College Projects with Documentation Contact on whatsapp 9999595223. Contact on: hitesh.xc@gmail.com or 9999595223 Try this Keyword C++ Programs

Advertisements