Sei sulla pagina 1di 10

JDBC Interview Questions.

1.What is web application?


An application which is running in the web and provides dynamic response to multiple end users
simultaneously is called web application.

2.What is client-server architecture?


The architecture which is useful for developing applications to sending the request and getting dynamic
response is called client-server architecture. We can also call as request and response architecture.

3.Is java technology?


Yes. Java provides rules or specifications to third party organizations in the form of interfaces by using
abstract methods.
Ex: JDBC is a technology. It will provide specifications to database organizations.

4.What is API and types of API?


API stands for Applications Programming Interface. It will encapsulate collection of classes and interface,
which are useful for developing applications (by using classes) and providing rules to third party organization
(by using interfaces)
We have three types of API’s.
1. User Define API’s.
2. Predefine API’s.
3. Third-Party provided API’s.

5.What are the drawbacks of File Management System?


The following are the drawbacks of File Management System.
Data redundancy
Limited User Access
No Data mapping mechanism
Less Security
Unable to maintain huge data
No Sequel Query Language support
No constraint concept supports

6.What is JDBC?
JDBC is a specification. JDBC is one standard mechanism to provides specifications to third party vendors like
oracle, mysql, db2 etc and get implementation from the third party vendors to communicating with persistence
store.

7.What is persistence?
The process of storing the permanently is called persistence.

8.What is persistence logic?


The logic which is useful for storing the persistence data permanently in persistence store is called persistence
logic.

9.What is persistence store?


The area or place, which is useful for storing persistence data permanently is called persistence store.

10.What is persistence technology?


The technology which is useful for developing persistence logic for doing persistence operations on
persistence data which is available in persistence store is called persistence technology.
Ex: JDBC, Hibernate, Spring ORM.

11.What is JDBC Driver?


JDBC Driver is a Connector or Translator Software, which is useful for converting from JAVA calls to
DATABASE calls and vice versa.
11) What are the mandatory components to communicating with database?
12.What are the mandatory components to
communicating with database?
There four mandatory components to communicating with database
a. Driver Name (Given by third party vendor)
b. URL
c. Username.
d. Password

13.What is ODBC?
It is translator software, which is useful for communicating with database, which has been developing on top
of native language like ‘C’. Java application developer never encourage to use this software, the reason is
internally it will use native logic which is not platform independent, securable, multithreaded and not
performance.

14.What is the use of bellow syntax?


Class.forName(String classname)
The above syntax is useful for loading the byte code at runtime and create java.lang.Class instance.
Java.lang.Class is a super class for types of “.class” file, that means java.lang.Class object can hold any type
class byte code. It will throwing checked exception that is java.lang.ClassNotFoundException.

15.What is the use of newInstance()?


It is useful for creating object for class by using loaded byte code. It will throw two checked exceptions.
a. Java.lang.InstantiationException
b. Java.lang.IllegalAccessException

16.Who is creating connection object in JDBC


technology?
JDBC driver implementation software will create connection object.
Ex: oracle.jdbc.dirver.OracleDriver
17.What is java.sql.DriverManager?
It is one type of helping object at java side, which is useful for collecting connection objects which are creating
by the JDBC driver implementation software and handover to java applications. Simply we can say
java.sal.DrierManager is java provided component which is useful for managing or operate drivers at java side.

18.What is the syntax to collect Connection object?


Connection con = DriverManager.getConnection(String,String,String);
Connection con = DriverManager.getConnection(String,Properties);

19.Which method using by Driver Implementation


software to creating connection object?
d.connect(String, Properties)

20. What is auto loading feature in JDBC?


Without mention driver name, automatically getting driver details and creating object connection object
handover to java application is called auto loading.

21.How many can we get the data from ResultSet?


There are two ways to get the data from ResultSet.
a. By using index number
b. By using column name.

22.What is the difference between ResultSet and


ResultSetMetaData?
ResultSet will talks about actual data about table whereas ResultSetmetaData will talks about table details like
number of columns, type of columns and size of the column etc….
23.What is use of executeQuery(-) method in statement
object?
It is useful for reading the data from table and create ResultSet object and copied.

24.How many objects are useful for execute query in


java?
There are three ways to execute queries from java application.
a. Java.sql.Statement
b. Java.sql.PreparedStatement
c. Java.sql.CallableStatement

25.How many methods are useful for execute the query in


statement object and return types?
There are three methods are in statement object to execute queries in java application
executeQuery(-) ? ResultSet
execute(-) ? boolean
executeUpdate(-) ? int

26.What is the main intention of the Statement object?


Statement object main intention is to work with static queries.

27.What is the main intention of the PreparedStatement


object?
PreparedStatement main intention is to work with dynamix queries

28.What is the main intention of the CallableStatement


object?
CallableStatement main intention is to work with stored procedures and functions.
29.How to create Statement object?
Statement st = con.createStatement();

30.How to create PreparedStatement object?


PreparedStatement ps = con.prepareStatement(String query)

31.How to create CallableStatement object?


CallableStatement cs = con.prepareCall(String )

32.What are the differences between Statement and


PrepareStatement?
Java.sql.Statement:
Which is useful work with static queries.
No need of sending query while creating object.
It is not support to work with BLOB, CLOB.
Every time build plan creating and destroyed.
Not suitable to work with dynamic queries without facing complexity.
Low at performance

Java.sql.PreparedStatement:
Which is useful work with dynamic and static queries.
We should send query while creating object.
It is support to work with BLOB, CLOB.
Every time build plan not creating and destroyed.
Not suitable to work with dynamic queries without facing
High at performance while working with looping queries.

33.What is build plan?


The steps which are taken by the Driver implementation software and database while executing the query is
called build plan.
1. First check query format valid or not
2. Checking table and related columns existed or not
3. Creating by ‘C’ language program based on query
4. Compile the ‘C’ language program.
5. Execute the ‘C’ language program
6. And fetching the result from database handover to java application

34.Is ResultSet suitable for travel throughout networks?


NO. The reason is it is not implements Serializable interface.

35.What is the difference between forward only and


scrollable resultset?
Forward only resultset is useful for only reading the data from top to bottom whereas scrollable resultset is
useful reading the data from top to bottom as well as bottom to top.

36.How many types of parameters do we have in JDBC


technology?
There are three types of parameters to work with database from java application.
a. IN : carrying the data from java to db.
b. OUT : carrying the data from db to java.
c. INOUT : carrying the data from java to db and vice versa.

37.What is the difference between java.util.Date and


java.sql.Date?
Java.util.Date will provides information about year, month, day, hours, minutes, seconds where as
java.sql.Date provides information about only years, month, day . java.sql.Date is the subclass of java.util.Date
ob ject.
38.What is the transaction management?
The process of taking database position from one state to another state either completely or none is called
transaction management.
We can achieve through by using following methods.
a. Commit()
b. Rollback()
c. Rollback(-)
d. setSavePoint()

39.What is the difference between rollback() and


rollback(-)?
Rollback() is useful for working with transaction management without savepoint scenario, where as rollback(-)
is useful for working with transaction management with savapoint scenario.

40.How to avoid auto commit mode in JDBC?


By default our connection object created auto commit mode true, that means if we are doing any operations,
those are reflected to database. By writing bellow statement we can change auto commit mode.
con.setAutoCommit(false)
con.setAutoCommit(true)

41.What is batch updates or batch processing?


The process of sending and executing multiple updateable queries in a single group is called batch updates.

42.What are methods are used to work with batch


updates?
Bellow methods are useful for work batch updates, those are
a. addBatch(-)
b. addBatch()
c. executeBatch()
43.Can we able to select query in batch updates?
No. We will get java.sql.BatchUpdateException: invalid batch command.
We can use only insert, update, delete queries in batch upadates.

44.What is the difference between relative(-) and


absolute(-)?
Relative(-) moves the cursor either backward or forward from current position of the cursor in the table, where
as abosolute(-) moves the cursor either from top to bottom or bottom to top irrespective cursor position in the
table.

45.What is difference between beforeFirst() and


isBeforeFirst()?
isBeforeFirst() will talks about, is our cursor position pointing to non-record or not, where as beforeFirst() will
forward the our cursor to non-record area.

46.What is difference between afterLast() and


isAfterLast()?
isAfterLast() will talks about, is our cursor position pointing to outside of last record or not, where as
afterLast() will forward the our cursor to next position of the last record.

47.What is the difference between isFirst() and first()?


isFirst() will check is our cursor pointing to first record of the table or not where as first() will forward the
control to first record of the table.

48.What is the difference between isLast() and last()?


isLast() will check is our cursor pointing to last record of the table or not where as last() will forward the
control to last record of the table.
49.What is the difference between isClosed() and close()
of ResultSet?
isClosed() of ResultSet will check is our ResultSet object closed or not where as close() of ResultSet will close
the resultset object, after call the close() of ResultSet, we can perform any operation on resultset object.

50.What is use of the DataBaseMetaData object?


The one jdbc object will provides more details about our databse, like version number, name, major and minor
version numbers, url and username and other details related to database.

51.What is connection pooling?


It is a collection of database connections managed to be available for java application objects.

52.What are drawbacks of ResultSet?


a. It is not implements java.io.Serializable interface.
b. Ihis object unable to travel throughout the network.
c. By default ResultSet is forward and read only mode.
d. If we want make our ResultSet as updateable and scrollable programmer itself declare ResultSet mode.
e. If we want to work ResultSet programmer should create Connection and Statement objects.
f. It is not developed on top Bean Mechanizam (No setters and getters).

Potrebbero piacerti anche