×

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 30 Drupal Interview Questions for 2024

1) What is Drupal? Drupal is an open source CMS (Content Management System) framework. It is written in php and provides rich set of tools to create web sites. 2) What are...

4 minutes read.

Top 15 Java Collections Interview Questions for 2024

1) What is Collections in Java? It is a framework which is used to store and manipulate the group of objects. 2) What are the commonly used methods of Collection interface in...

2 minutes read.

Top 30 Cobol Interview Questions for 2024

1) What is COBOL? COBOL is a programming language which is used for finance, business and administrative systems for companies. COBOL is stands for Common Business Oriented Language. 2) What are the features...

4 minutes read.

Top 15 XML Interview Questions for 2024

1) What is XML? XML (eXtensible Markup Language) is designed to transport and store data. It has user executive tags i.e. no pre-defined tags used as in HTML. This language is...

2 minutes read.

Top 31 Dart Programming Interview Questions for 2024

1) What is Dart? Dart is an application programming language. It is used to build web, server and mobile applications. 2) Who is the developer of Dart? Google is the developer of Dart. 3)...

6 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 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 15 AWS Interview Questions for 2024

1) What is AWS? AWS stands for Amazon Web Services. It is a cloud web hosting platform that offers flexible, scalable, reliable, easy-to-use, and cost-effective solutions. 2) What is Cloud Computing? It is...

2 minutes read.

Top 16 Arduino Interview Questions for 2024

1) What is Arduino? Arduino is an open source electronic platform. It is based on easy-to-use hardware and software. It able to read input signal. It is used to write and...

2 minutes read.

Top 15 RESTful Web Services Interview Question for 2024

1) What is REST? REST is web standards based architecture and stands for REpresentational State Transfer. It uses HTTP Protocol for data communication. Here, everything is a resource. 2) What are the HTTP methods used...

2 minutes read.

Top 15 Erlang Interview Questions for 2024

1) What is Erlang÷ Erlang is an open source programming language. It is used to build massively scalable soft real-time systems. It has runtime environment. It supports concurrency, fault tolerance and...

2 minutes read.

Top 14 Web icon Interview Questions for 2024

1) What is Web Icon? Web Icon is a symbol that is used to represent a specific action or a capability on a webpage. It is used in documents as well...

5 minutes read.

Top 50 HTML Interview Questions for 2024

1) What is HTML? HTML stands for Hyper Text Markup Language. It is used for creating web pages and web applications. HTML documents are made up of two things: the content and the tags. 2) What are...

10 minutes read.

Top 15 MATLAB Interview Questions for 2024

1) What is MATLAB? MATLAB (matrix laboratory) is fourth-generation programming language. It allows matrix manipulations, implementations of algorithm and many more. 2) Who developed MATLAB? MATLAB is developed by MathWorks. 3) In which language...

2 minutes read.

Top 10 WCF Interview Questions for 2024

  1. What is WCF? Windows Communication Foundation (WCF), earlier known by the name Indigo, is a run-time platform and a set of APIs in the .NET Framework for building, configuring, and...

7 minutes read.

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 Website Development Interview Questions for 2024

1) What is Website Development? Website Development is a process that includes following steps. web design web content development client-side or server-side scripting network security configuration etc 2) What are the skills...

3 minutes read.

Top 15 Ext Js Interview Question for 2024

1) What is Ext Js? Ext Js refers to Extended JavaScript. Ext JS is a JavaScript framework used to built interactive cross platform web application. 2) What are the features of Ext...

3 minutes read.

Top 15 Hadoop Interview Questions for 2024

1) What is Hadoop? Hadoop is a framework which is used to store and process Big Data. It is a distributed computing platform and helps in analyzing Big Data. 2) What are the...

2 minutes read.