5.JDBC Imp Questions
5.JDBC Imp Questions
Question: 1
What is JDBC?
It is an API. The latest version of JDBC API is (3.0)
java.sql
javax.sql
Advantages:
The JDBC API can be used to interact with multiple data sources in a distributed heterogeneous
environment.
It can switch over to any backend database without changing java code or by minute changes.
Question: 2
Question: 3
Two tier model: In this method, Java applications together interact directly with the database.
A JDBC driver is required to communicate with the particular database management system that
is being accessed.
SQL statements are sent to the database and the results are given to user.
This model is referred to as client/server configuration where user is the client and the machine
that has the database is called as the server.
Three tier model: A middle tier is introduced in this model. The function of this model are
Collection of SQL statements from the client and handing it over to the database,
Question: 4
Most existing JDBC drivers (DataSource instances) implement this interface. It provides the
following methods for obtaining PooledConnections:
Such connections can be closed by issuing connection.close(), but it’s only a logical closing, not
physical.
Question: 5
Question: 2
java.sql.Driver,
Connection,
Statement,
PreparedStatement,
CallableStatement,
ResultSet,
ResultSetMetaData,
DatabaseMetaData.
Question: 3
Question: 4
The new JDBC Standard Extension API, an integral part of Enterprise Java Beans (EJB)
technology, allows you to write distributed transactions that use connection pooling, and it also
makes it possible to connect to virtually any tabular data source, including files and spread
sheets.
Batch Updates
Connection Pooling
Distributed transactions
set autocomit()
Question: 5
What is JDBC?
JDBC is a set of Java API for executing SQL statements.
This API contains of a set of classes and interfaces to enable programs to write pure Java
Database applications.
JDBC is a layer of abstraction that allows users to choose between database. It allows you to
change to a different engine and to write to a Single API.
JDBC allows you to write database applications in Java without having to concern yourself with
the underlying details of a particular database.
JDBC standards for Java Database Connectivity. It is a specification given by Sun Microsystems
and standards followed by X/Open SAG (SQL Access Group) CLI (Call Level Interface) to
interact with the DB.
Question: 6
Question: 7
ODBC makes use of pointers which have been removed totally from Java.
ODBC mixes simple and advanced features together and has complex options for simple queries.
But JDBC is designed to keep things simple while allowing advanced capabilities when required.
ODBC requires manual installation of the ODBC driver manager and driver on all client
machines. JDBC drivers are written in Java and JDBC code is automatically installable, secure,
and portable on all platforms.
JDBC API is a natural Java interface and is built on ODBC. JDBC retains some of the basic
features of ODBC.
Question: 8
SQL Exception
SQL Warning
Question: 9
Load the driver class using class.forName(driverclass) and Class.forName() loads the driver
class and passes the control to DriverManager class.
Using DataSource:
DataSource is used instead of DriverManager in Distributed Environment with the help of JNDI.
Question: 10
Register a driver
Specify a database
Submit a query
Receive results
Question: 2
Question: 3
Driver layer
Application layer
The Application layer begins after putting a request to the Driver Manager for the connection.
The application needs the connection for creating the Statement kind of objects by which the
results are obtained.
Question: 5
In fact most of the classes available in JDBC API are interfaces, where Driver vendors must
provide implementation for the above said interfaces.
Java JDBC Interview Questions for Freshers Pdf
Question: 6
Prepared statements and JDBC driver are linked with each other.
We can bind drivers with columns by triggering the query into the database.
When we execute Connection prepareStatement(), all the columns bindings take place, in order
to reduce the time.
Question: 7
<subprotocol>: The subprotocol is used to identify a database driver, or the name of the database
connectivity mechanism, chosen by the database driver providers.
<subname>: The syntax of the subname is driver specific. The driver may chosen any syntax
appropriate for its implementation.
Question: 8
Question: 9
Due to failing to load the appropriate JDBC drivers before calling the getConnection method.
It can be specifying an invalid JDBC URL, one that is not recognized by JDBC driver.
This error can occur if one or more the shared libraries needed by the bridge cannot be loaded.
Question: 10
The setNull method takes index and SQL Types as arguments, for example
ps.setNull(10, java.sql.Types.INTEGER);