×

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 20 C Programming | Coding Interview Questions for 2024

Most Frequently asked C programming | Coding Interview Questions and answer for Fresher C is a powerful high-level programming language.  It is a fast, portable and available for all platforms. C...

15 minutes read.

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...

4 minutes read.

Top 26 SEO Interview Questions for 2024

Most Frequently asked SEO Interview Questions and Answers for Fresher and Experienced 1) What is SEO? SEO stands for Search Engine Optimization. It is a set of processes followed by website owners...

4 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.

Top 30 Less Interview Questions for 2024

1) What is Less? Less is a dynamic style sheet language that can be compiled in to CSS (Cascading style Sheet). It runs on client side and server side. It is...

4 minutes read.

Top 15 XHTML Interview Questions for 202

1) What is XHTML? XHTML (Extensible Hyper Text Markup Language) it is similar to the HTML but has some strict rule than HTML. It is said to be HTML defined as...

3 minutes read.

SSRS Interview Questions

1. What is SSRS? The Microsoft SQL Server Reporting Service (SSRS) is a server-based reporting platform. It allows you to produce structured reports. The reports are generally represented in the form of data, graph,...

5 minutes read.

Top 16 Ionic Interview Questions for 2024

Top 20 Ionic Interview Questions and Answers for Freshers 1) What is Ionic framework? Ionic is open source HTML5 framework used for hybrid mobile application development. It provides tools and services for...

3 minutes read.

Top 10 Java Swing Interview Questions for 2024

1) What is Java Swing? It is a part of JFC (Java Foundation Classess) that is used to create window-based applications. Java Swing components are platform independent and lightweight . 2) What is...

3 minutes read.

Top 15 PhantomJS Interview Question for 2024

1) What is PhantomJS? PhantomJS is a lightweight headless scripted browser built on WebKit. It is used for automation web page interaction. 2) Why it is called as headless browser? PhantomJS called as...

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.

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 15 Java Multithreading Interview Questions for 2024

1) What is Multithreading in Java ? It is a process of executing multiple threads simultaneously. It is used to achieve multitasking. It is mostly used in animation and games etc. 2) What are...

4 minutes read.

Top 50 ReactJS Interview Questions for 2024

Top 50 Frequently asked ReactJS Interview Questions Q-1. What is React? Ans-1 React is a front-end JavaScript library which is developed by Facebook in 2011. It follows the component-based approach and allows us to...

15 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 30 Web2py Framework Interview Questions for 2024

1) What is Web2py Framework? Web2py is an open source web application framework. It is written in the Python programming language. It allows web developers to design and develop dynamic web...

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

1) What is ExpressJs? Express Js is a framework for node.js which is light-weight and fast. It is used to develop web and mobile applications. 2) What are the features of ExpressJs? Following...

4 minutes read.

Top 15 Java BeanUtils Interview Questions for 2024

1) What is Java BeanUtils? Java BeanUtils is a design pattern component of the Apache Commons. It facilitates architecture for Java language which is derived from JavaAPI. It helps to set...

3 minutes read.

Top 13 SAS Interview Questions for 2024

1. What is SAS and its functions? SAS (Statistical Analysis System) is statistical software designed by SAS Institute in 1960 for data inspection and report writing. SAS runs on Windows, UNIX...

5 minutes read.