Professional Documents
Culture Documents
When database call is made using JDBC,the driver translates the request into vendor-
specific API calls.
The database will process the requet and sends the results back through the Native API
,which will
Forward them back to the JDBC driver. The JDBC driver will format the results to
conform to the JDBC
Standard and return them to the application.
7. What are the Advantages & Disadvantages of Type-2, Type-4 Drivers over JDBC-
ODBC bridge driver (Type-1)?
A. Type-2 & Type-4 are given
8. Which Driver is preferable for using JDBC API in Applets?
A. Type-4 Drivers.
9. Write the Syntax of URL to get connection? Explain?
A. Syntax: - jdbc :< sub protocol> :< sub name>
Jdbc -----> is a protocol .This is only allowed protocol in JDBC.
<Sub protocol> ----> the sub protocol is used to identify a database driver, or the
Name of the database connectivity mechanism, chosen by the database driver providers.
<Sub name> -------> the syntax of the sub name is driver specific. The driver may choose
any syntax appropriate for its implementation
Ex: jdbc: odbc: dsn
Jdbc: oracle: oci8:@ database name.
Jdbc: orale: thin: @ database name: port number: SID
24. In which interface the methods commit() & rollback() are defined ?
A. java.sql.Connection interface
25. How to store images in database?
A. Using binary streams (i.e. getBinaryStream() ,setBinaryStream()). But it is not
visible in database; it is stored in form of bytes, to make it visible we have to use any
one front-end tool.
26. How to check null value in JDBC?
A. By using the method wasNull() in ResultSet ,it returns boolean value.
Returns whether the last column read had a value of SQL NULL.
Note that you must first call one of the getXXX methods on a column to try to read its
value and then call the method wasNull to see if the value read was SQL NULL.
27.Give one Example of static Synchronized method in JDBC API?
A. getConnection() method in DriverManager class.Which is used to get object of
Connection interface.
28.What is a Connection?
A. Connection is an interface which is used to make a connection between client and
Database (i.e. opening a session with a particular database).
29.what is the difference between execute() ,executeUpdate() and executeQuery() ?
where we will use them?
A. execute() method returns a boolean value (i.e. if the given query returns a resultset
then it returns true else false),so depending upon the return value we can get the
ResultSet object (getResultset())or we can know how many rows have bean affected by
our query (getUpdateCount()).That is we can use this method for Fetching queries and
Non-Fetching queries. Fetching queries are the queries which are used to fetch the
records from database (i.e. which returns resutset) ex: Select * from emp.
Non-Fetching queries are the queries which are used to update,insert,create or delete the
records from database
ex: update emp set sal=10000 where empno=7809.
executeUpdate() method is used for nonfetching queries.which returns int value.
executeQuery() method is used for fetching queries which returns ResulSet object ,Which
contains methods to fetch the values.
30.How is jndi useful for Database connection?
A.