• Skip to main content
  • Skip to primary sidebar
  • Skip to secondary sidebar
  • Skip to footer

Computer Notes

Library
    • Computer Fundamental
    • Computer Memory
    • DBMS Tutorial
    • Operating System
    • Computer Networking
    • C Programming
    • C++ Programming
    • Java Programming
    • C# Programming
    • SQL Tutorial
    • Management Tutorial
    • Computer Graphics
    • Compiler Design
    • Style Sheet
    • JavaScript Tutorial
    • Html Tutorial
    • Wordpress Tutorial
    • Python Tutorial
    • PHP Tutorial
    • JSP Tutorial
    • AngularJS Tutorial
    • Data Structures
    • E Commerce Tutorial
    • Visual Basic
    • Structs2 Tutorial
    • Digital Electronics
    • Internet Terms
    • Servlet Tutorial
    • Software Engineering
    • Interviews Questions
    • Basic Terms
    • Troubleshooting
Menu

Header Right

Home » Servlet » Database » Major Classes and Interfaces used to developing Java Application.
Next →
← Prev

Major Classes and Interfaces used to developing Java Application.

By Dinesh Thakur

Some of major classes and interfaces which are frequently used while developing a Java application are as follows:

• DriverManager class

• Driver interface

• Connection interface

• Statement interface

We’ll be covering the following topics in this tutorial:

  • DriverManagerClass
  • Driver Interface
  • Connection Interface
  • Statement Interface
  • ResultSet Interface

DriverManagerClass

It is a predefined class present/declared in java.sql package. It is a non-abstract class in the JDBC API. It has no constructor which implies that this class cannot be inherited or initialized directly.

All the methods or properties of this class are declared as static, so it is not necessary to construct an object of DriverManager Class. We can call these static methods using class name.

The main responsibility of the DriverManager class is preparing a connection by using Driver implementation that accepts the given JDBC URL.

Methods in DriverManager

(a) public static Connection getConnection (String url, String user name, String pswd);

Establishes connection between driver and database. This class selects a driver from the list of drivers and creates a connection by checking user parameter for which the connection is being made. Password parameter represents the password of the user.

(b) public static Driver getDriver (String url) throws SQLException

Locates the requested driver in the DriverManager class. The URL parameter specifies the URL of requested driver.

(c) public static void register (Driver drvr) throws SQLException:

Registers a requested driver with DriverManager Class.

(d) public static void deregister (Driver drvr) throws SQLException

Drops a driver from the list of the driver maintained by DriverManager.

Driver Interface

It is a predefined interface present in java.sql. package. It is a basic interface that every JDBC driver provider has to implement. The java.sql.Driver is an Interface defined under JDBCAPI to describe an object that is responsible to establish connection to database. All the driver classes implement this interface to connect to a database.

Methods in Driver Interface

(a) public Connection connect (String url, Properties info)

This method establishes connectivity with database. The URL parameter specifies a URL that describes the database details to which the driver is to be connected. The info parameter specifies the information of the tag/value pair used in driver.

Connection Interface

It is an interface present in java.sql package. This interface defines an abstraction to access the session, established with the database server. The JDBC connection helps to perform the following operation:

• Create JDBC Statement

• Control local transaction

Methods in Connection Interface

(a) public void close () throws SQLException

Closes the connection and releases the connection object associated with the connected database.

(b) public Statement createStatement () throws SQLException

Create a Statement object to send sql statements to the specified database.

(c) public PreparedStatement prepareStatement (String sql) throws SQLException

Create a PreparedStatement object to send sql statements over a connection.

(d) public CallableStatement prepareCall (String sql) throws SQLException

Create a CallableStatement object for calling database stored procedures.

(e) public void commit () throws SQLException

Commits the changes made in the previous commit and releases any database locks held by the current Connection object.

(f) public void rollback () throws SQLException

Rolls back all the transactions and releases any locks that are currently held by the Connection object.

Statement Interface

It is a predefined interface present in java.sql package. It is a part of JDBC API that abstracts an object. It is responsible to execute sql statement and return the result. A

Statement object can open a single ResultSet object at a time.

The PreparedStatement interface is dealing with IN parameter whereas the CallableStatement interface deals with both IN and OUT.

Methods of Statement Interface

(a) public int executeUpdate (String sql) throws SQLException

Execute the Insert, Update and Delete Statement or the SQL DDL statements.

(b) public ResultSet executeQuery (String sql) throws SQLException

Execute a sql command and return a single ResultSet.

(c) public void close () throws SQLException

Closes the Statement object, therefore, it releases its control from the database and also from the connection.

(d) public ResultSet getResultSet () throws SQLException

Retrieves the current Resultset object generated by Statement object.

(e) public Connection getConnection () throws SQLException

Accepts the Connection object made to the database.

ResultSet Interface

This interface provides methods for the retrieval of data returned by an SQL statement execution. A ResultSet maintains a cursor pointing to its current row of data. The most often used methods, namely, getXXX and updateXXX methods are present in this interface.

Methods in ResultSet

(a) public booleannext () throws SQLException

Moves the cursor down one row from its current position.

(b) public void close () throws SQLException

Releases this ResultSet object’s database and JDBC resources immediately instead of waiting for this to happen when it is automatically closed.

(c) public booleanwasNull () throws SQLException

Reports whether the last column read had a value of SQL NULL.

(d) public StringgetXXX (int columnIndex) throws SQLException

Retrieves the value of the designated column in the current row of this ResultSet object as per the type of data.

(e) public void beforeFirst () throws SQLException

Moves the cursor to the front of this ResultSet object, just before the first row.

(f) public void afterLast () throws SQLException

Moves the cursor to the end of this ResultSet object, just after the last row.

(g) public booleanabsolute (int row) throws SQLException

Moves the cursor to the given row number in this ResultSet object.

(h) public booleanprevious () throws SQLException

Moves the cursor to the previous row in this ResultSet object.

(i) public void deleteRow () throws SQLException

Deletes the current row from this ResultSet object and from the underlying database.

(j) public void insertRow () throws SQLException

Inserts the contents of the insert row into this ResultSet object and into the database.

You’ll also like:

  1. Multiple Interfaces in Java with Example
  2. Extending Interfaces in Java Examples
  3. What is Application Program and application software?
  4. Discuss the major types of Information System
  5. Write Major Problems in System (Software) Development
Next →
← Prev
Like/Subscribe us for latest updates     

About Dinesh Thakur
Dinesh ThakurDinesh Thakur holds an B.C.A, MCDBA, MCSD certifications. Dinesh authors the hugely popular Computer Notes blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps.

Dinesh Thakur is a Freelance Writer who helps different clients from all over the globe. Dinesh has written over 500+ blogs, 30+ eBooks, and 10000+ Posts for all types of clients.


For any type of query or something that you think is missing, please feel free to Contact us.


Primary Sidebar

SQL Tutorials

SQL Tutorials

  • SQL - Home
  • SQL - Select
  • SQL - Create
  • SQL - View
  • SQL - Sub Queries
  • SQL - Update
  • SQL - Delete
  • SQL - Order By
  • SQL - Select Distinct
  • SQL - Group By
  • SQL - Where Clause
  • SQL - Select Into
  • SQL - Insert Into
  • SQL - Sequence
  • SQL - Constraints
  • SQL - Alter
  • SQL - Date
  • SQL - Foreign Key
  • SQL - Like Operator
  • SQL - CHECK Constraint
  • SQL - Exists Operator
  • SQL - Drop Table
  • SQL - Alias Syntax
  • SQL - Primary Key
  • SQL - Not Null
  • SQL - Union Operator
  • SQL - Unique Constraint
  • SQL - Between Operator
  • SQL - Having Clause
  • SQL - Isnull() Function
  • SQL - IN Operator
  • SQL - Default Constraint
  • SQL - Minus Operator
  • SQL - Intersect Operator
  • SQL - Triggers
  • SQL - Cursors

Advanced SQL

  • SQL - Joins
  • SQL - Index
  • SQL - Self Join
  • SQL - Outer Join
  • SQL - Join Types
  • SQL - Cross Join
  • SQL - Left Outer Join
  • SQL - Right Join
  • SQL - Drop Index
  • SQL - Inner Join
  • SQL - Datediff() Function
  • SQL - NVL Function
  • SQL - Decode Function
  • SQL - Datepart() Function
  • SQL - Count Function
  • SQL - Getdate() Function
  • SQL - Cast() Function
  • SQL - Round() Function

Other Links

  • SQL - PDF Version

Footer

Basic Course

  • Computer Fundamental
  • Computer Networking
  • Operating System
  • Database System
  • Computer Graphics
  • Management System
  • Software Engineering
  • Digital Electronics
  • Electronic Commerce
  • Compiler Design
  • Troubleshooting

Programming

  • Java Programming
  • Structured Query (SQL)
  • C Programming
  • C++ Programming
  • Visual Basic
  • Data Structures
  • Struts 2
  • Java Servlet
  • C# Programming
  • Basic Terms
  • Interviews

World Wide Web

  • Internet
  • Java Script
  • HTML Language
  • Cascading Style Sheet
  • Java Server Pages
  • Wordpress
  • PHP
  • Python Tutorial
  • AngularJS
  • Troubleshooting

 About Us |  Contact Us |  FAQ

Dinesh Thakur is a Technology Columinist and founder of Computer Notes.

Copyright © 2025. All Rights Reserved.

APPLY FOR ONLINE JOB IN BIGGEST CRYPTO COMPANIES
APPLY NOW