×

Top 15 Java JDBC Interview Questions for 2024

1) What are the types of JDBC Drivers in Java?

JDBC Drivers are of four types are:
  • JDBC-ODBC bridge driver
  • Native-API driver
  • Network Protocol driver
  • Thin driver

2) What are the five steps to connect to the database in Java?

Five steps to connect to the database are :
  • Step1: Register the driver class
  • Step2: Creating connection
  • Step3: Creating statement
  • Step4: Executing queries
  • Step5: Closing connection

3) What are the commonly used methods of DriverManager class in Java?

Commonly used methods of DriverManager class are:
  • public static void registerDriver(Driver driver)
  • public static void deregisterDriver(Driver driver)
  • public static Connection getConnection(String url)
  • public static Connection getConnection(String url,String userName,String password)

4) What are the commonly used methods of Statement interface in Java?

The commonly used methods of Statement interface in java are:
  • public ResultSet executeQuery(String sql)
  • public int executeUpdate(String sql)
  • public boolean execute(String sql)
  • public int[] executeBatch()

5) What are the commonly used methods of ResultSet interface in Java?

The commonly used methods of ResultSet interface are:
  • public boolean next()
  • public boolean previous()
  • public boolean first()
  • public boolean last()
  • public boolean absolute(int row)
  • public boolean relative(int row)
  • public int getInt(int columnIndex)
  • public int getInt(String columnName)
  • public String getString(int columnIndex)
  • public String getString(String columnName)

6) What are the commonly used methods of PreparedStatement interface in Java?

The commonly used methods of PreparedStatement interface are:
  • public void setInt(int paramIndex, int value)
  • public void setString(int paramIndex, String value)
  • public void setFloat(int paramIndex, float value)
  • public void setDouble(int paramIndex, double value)
  • public int executeUpdate()
  • public ResultSet executeQuery()

7) What are the commonly used methods of ResultSetMetaData interface in Java?

The commonly used methods of ResultSetMetaData interface are:
  • public int getColumnCount()throws SQLException
  • public String getColumnName(int index)throws SQLException
  • public String getColumnTypeName(int index)throws SQLException
  • public String getTableName(int index)throws SQLException

8) What are the commonly used methods of DatabaseMetaData interface in Java?

The commonly used methods of DatabaseMetaData interface are:
  • public String getDriverName()throws SQLException
  • public String getDriverVersion()throws SQLException.
  • public String getUserName()throws SQLException
  • public String getDatabaseProductName()throws SQLException
  • public String getDatabaseProductVersion()throws SQLException
  • public ResultSet getTables(String catalog, String schemaPattern, String tableNamePattern, String[] types)throws SQLException

9) What are the types of ResultSet in Java?

There are three types of ResultSet in Java are:
  • TYPE_FORWARD_ONLY
  • TYPE_SCROLL_INSENSITIVE
  • TYPE_SCROLL_SENSITIVE

10) How can I connect Java Application with Oracle database in java?

Example:
import java.sql.*;    
class OracleConn  
{    
public static void main(String args[])  
{    
try  
{    
Class.forName("oracle.jdbc.driver.OracleDriver");    
Connection con=DriverManager.getConnection(    
"jdbc:oracle:thin:@localhost:1521:xe","system","oracle");  // Here system is username and oracle is password.  
Statement stmt=con.createStatement();    
ResultSet rs=stmt.executeQuery("select * from emp");    
while(rs.next())    
System.out.println(rs.getInt(1)+"  "+rs.getString(2)+"  "+rs.getString(3));    
con.close();    
}  
catch(Exception e)  
{   
System.out.println(e);  
}    
}    
}

11) How can I connect Java Application with mysql database in java?

Example:
import java.sql.*;    
class MysqlConn  
{    
public static void main(String args[])  
{    
try  
{    
Class.forName("com.mysql.jdbc.Driver");    
Connection con=DriverManager.getConnection(    
"jdbc:mysql://localhost:3306/atul","root","root");   // Here atul is database name and root is username and password.  
Statement stmt=con.createStatement();    
ResultSet rs=stmt.executeQuery("select * from emp");    
while(rs.next())    
System.out.println(rs.getInt(1)+"  "+rs.getString(2)+"  "+rs.getString(3));    
con.close();    
}  
catch(Exception e)  
{  
System.out.println(e);  
}    
}    
}

12) How many packages are available in JDBC API?

There are two types of packages are available in JDBC API:
  • Java.sql
  • Javax.sql

13) What are the commonly used implementation classes of RowSet interface in Java?

The commonly used implementation classes of RowSet interface are:
  • JdbcRowSet
  • CachedRowSet
  • WebRowSet
  • JoinRowSet
  • FilteredRowSet

14) What are the advantages of RowSet interface in Java?

Advantages of RowSet interface are:
  • easy to use
  • Flexible to use
  • Scrollable
  • Updatable bydefault

15) Result Sets index starts with 0 or 1?

ResultSet index starts with 1.

Related Topics

Top 14 Materialize CSS Framework Interview Questions for 2024

1) What is Materialize? Materialize is a CSS framework that contains library file. It is created with CSS, JavaScript and HTML. It helps to create attractive, reliable and functional web pages...

7 minutes read.

Top 15 Servlet Interview Questions for 2024

1) What is Servlet? It is a technology used to create web applications. It is a web component which is used to create dynamic web pages. It consists of many interfaces and classess...

2 minutes read.

Top 16 Yii PHP Framework Interview Questions for 2024

1) What is Yii Framework? Yii is an open source, web application framework based on MVC. It is written in PHP and used to design PHP applications. This application was started...

4 minutes read.

Top 22 MariaDB Interview Question for 2024

1) What is MariaDB? It is a community based database devoloped by MySQL Devolopers. It provides same features as MySQL also, can be said that it is a replacement of MySQL. 2)...

3 minutes read.

Top 26 CouchDB interview questions for 2024

1) What is CouchDB? CouchDB is a document typed database server which can be accessed through RESTful JSON API. It is a schema free and Ad-hoc database with a flat address...

4 minutes read.

WebSockets Interview Questions

1) What is Web Sockets? Web Sockets is a two way communication between the clients and the servers. Here, the clients and servers both the parties can communicate and exchange data...

3 minutes read.

Top 10 GWT Interview Questions for 2024

1) What is Google Web Toolkit (GWT)? GWT (Google Web Toolkit) is a development toolkit. It is used to develop Ajax web applications using Java. GWT compiler translates Java sour ce...

2 minutes read.

Django Interview Questions for 2024

Django is an open-source python web framework. It is very popular due to the functionalities it offers. It uses the Model-View-Template architecture. Many giant organizations are using Django as their...

10 minutes read.

Top 25 R programming Language Interview Questions for 2024

1) What is R programming language? R is an open source programming language. It is software environment for statistical computing and graphics. It compiles and runs on a wide variety of...

4 minutes read.

Polymer.js Interview Questions

1) What is Polymer.js? Polymer.js is an open source JavaScript library. It is developed by Google. It is used to develop web applications for using of web components like HTML. 2) Describe...

3 minutes read.

Top 18 Blockchain Interview Questions and Answers for 2024

Top 20 Commonly Asked Blockchain Interview Questions and Answers 1. What do you understand by Blockchain? Blockchain is a chain of blocks made up of digital pieces of information or can be defined as...

6 minutes read.

Top 15 NodeJS Interview Questions for 2024

1) What is NodeJs? NodeJs is open source JavaScript based feamework used to develop I/O intensive web application. It is collections of JavaScript library and runtime environment. It is used to...

3 minutes read.

Top 30 Swift Interview Questions for 2024

1) What is Swift? It is an innovative programming language developed by Apple Inc. It is used for creating applications for iOS and OS X. 2) What are the features of Swift Programming? Features...

4 minutes read.

Top 30 DBMS Interview Questions for 2024

1) What is DBMS? DBMS (Data Base Management System) is a technology for managing data of database i.e. Create, Update, Delete, Alter. 2) What is a Database System? It is defined as collection...

4 minutes read.

PhoneGap Interview Questions 2024

Top 50 Phonegap Interview Questions with their Answers Once you have acquired practical knowledge of the PhoneGap technology, you will now be able to search for a job as a mobile...

9 minutes read.

Top 30 JSF Interview Questions for 2024

1) What is JSF? JSF stands for Java Server Faces is a Java-Based web application framework. JSF (Java Server Faces) provides a facility to connect UI widgets with data sources. 2) What are...

4 minutes read.

Top 15 SVG Interview Questions for 2024

1) What is SVG? SVG stands for Scalable Vector Graphics, It is XML based format used to draw dimentional vector images. It is a W3C standard. SVG supports all image formats. 2) What are...

2 minutes read.

Top 15 Framework7 Interview Questions for 2024

1) What is Framework7? Framework7 is an open source mobile HTML framework. It is used todevelop hybrid mobile apps for iOS and Android devices. 2) Why, framework7 is popular? There are various reasons...

8 minutes read.

Top 30 CodeIgniter interview Questions for 2024

1) What is CodeIgniter? CodeIgniter is an open source PHP framework. It is used to develop web applications and websites. It is loosely based on MVC pattern and easy to use...

4 minutes read.

Top 30 Ruby on Rails Interview Questions for 2024

1) What is Ruby on Rails? It is a server-side web application framework. It is an open source ruby framework which is used for developing database-backed web applications. Here, no compilation phase is...

4 minutes read.