Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/purvgwtw/public_html/tutorials/common.php on line 7
JDBC Interview Questions & Answers
Sponsered Links
Sponsered Links

JDBC Interview Questions & Answers

 How can you establish connection?
To establish a connection you need to have the appropriate driver connect to the DBMS. The following line of code we use: String url = “jdbc:odbc:Fred”; Connection con = DriverManager.getConnection(url, “Fernanda”, “J8?);

Define different types of Statements?

There are three types of statements • Regular statement • prepared statement • callable statement

What are the components of JDBC?

The two major components of JDBC are Connection Pooling and Data Sources.

Define metadata?

Metadata is data about data. In JDBC, there are two types 1. Describing information about the Result set object. i 2. describes about the database connection

Differentiate between local and global transaction?

A transaction is atomic unit of Work. Transactions can be divided into two categories. 1.Local Transactions: These transactions are confined to the objects which reside inside one particular JVM. 2.Global Transactions:These transactions may encapsulate objects which are distributed on various JVM's.

What is the technique to call a Stored Procedure from JDBC?

The first step is to create a CallableStatement object. As with as a Statement an and PreparedStatement objects, this is done with an open Connection object. E.g.CallableStatement cs = con.prepareCall("{call SHOW_SUPPLIERS}"); ResultSet rs = cs.executeQuery();

Why JDBC objects generate SQLWarnings?

Connections, Statements and ResultSets all have a getWarnings method that allows retrival.The prior ResultSet warnings are cleared on each new read and prior Statement warnings are cleared with each new execution.

What are the components of JDBC?

The two major components of JDBC is One implementation interface for the database manufacturers, the other implementation interface for application and applet writers.

How web server is connected with appliction server?

All the application server requires to the information about the installed web server's port and name, through these entries it creates a connector and stored. This connector is used to communicate with Application server.

Differentiate between Rowset and Resultset?

RowSets are a part of JDBC 2.0 API. Essentially a row set is a JavaBean that contains database data. The implementation is store the data offline, or it can simply wrap a connection to make a result set look like a JavaBean. You could even use a row set to access data communicating over HTTP to a servlet, which provides the data for the bean.

How can we insert images into a Mysql database?

This code is snip shows the basics: File file = new File(fPICTURE); FileInputStream fis = new FileInputStream(file); PreparedStatement ps = ConrsIn.prepareStatement("insert into dbPICTURE values (?,?)"); ps.setString(1,file.getName()); ps.setBinaryStream(2,fis,(int)file.length()); ps.close(); fis.close();

Define advantage of using a PreparedStatement?

For SQL statements that are executed repeatedly, using a PreparedStatement object would almost always be s faster than using a Statement object. This is because creating a PreparedStatement object by explicitly giving the SQL statement causes the statement to be precompiled within the database immediately. Typically, PreparedStatement objects are used for the SQL statements that take parameters.

How does the JDBC work?

The Java Database Connectivity (JDBC) is used to whenever a Java application should communicate with a relational database for which a JDBC driver exists. Main JDBC classes: • DriverManager. Manages a list of database drivers. • Driver. The database communications link, handling all communication with the database. • Connection. Interface with all the methods for contacting a database • Statement. Encapsulates an SQL statement which is passed to the database to be parsed, compiled, planned and executed. • ResultSet. The answer/result from a statement. A ResultSet is a fancy 2D list which encapsulates all outgoing results from a given SQL query.

Sponsered Links
Latest Updates
All Content of this site is for learning only. We do not warrant the correctness of its content. The risk from using it lies entirely with the user. While using this site, you agree to have read and accepted our terms of use and privacy policy.
Copyright © 2014 PURVACOMPUTERS.COM All Right Reserved