JDBC Introduction

With Core Java knowledge we can develop Stand Alone Applications. The Applications which are running on a Single Machine are called Stand Alone Applications.


Calculator, MS Word, Notepad, any Core Java Application,

If we want to develop Web Applications then we should go for Advanced Java. The Applications which are providing Services over the Web are called Web Applications.


In Java we can develop Web Applications by using the following Technologies.

  • JDBC
  • Servlets
  • JSP’s

Where ever Presentation Logic is required i.e. to display something to the End User then we should go for JSP i.e. JSP meant for View Component.


  • Display login page
  • Display inbox page
  • Display error page
  • Display result page etc.

Where ever some Processing Logic is required then we should go for Servlet i.e. Servlet meant for Processing Logic/ Business Logic. Servlet will always work internally.


  • Verify User
  • Communicate with Database
  • Process End User’s Data etc.

From Java Application (Normal Java Class OR Servlet) if we want to communicate with Database then we should go for JDBC.


  • To get Astrology Information from Database
  • To get Mails Information from Database etc.

In Java there are 3 Editions are available

  1. Java Standard Edition (JSE | J2SE)
  2. Java Enterprise Edition (JEE | J2EE)
  3. Java Micro Edition (JME | J2ME)

JDBC is the Part of JSE and Servlets and JSP’s are the Part of JEE.

1. Driver

To convert Java specific calls into Database specific calls and Database specific calls into Java calls.

2. Connection

By using Connection, Java Application can communicate with Database.

3. Statement

By using Statement Object we can send our SQL Query to the Database and we can get Results from Database.

4. ResultSet

ResultSet holds Results of SQL Query.

Steps for JDBC Application
  1. Load and Register Driver
  2. Establish Connection between Java Application and Database
  3. Create Statement Object
  4. Send and Execute SQL Query
  5. Process Results from ResultSet
  6. Close Connection


import java.sql.*; 

 * @author ashok.mariyala
public class JdbcDemo { 
   public static void main(String[] args) throws Exception { 
      Connection con=DriverManager.getConnection("jdbc:odbc:demodsn","scott","tiger"); 
      Statement st = con.createStatement(); 
      ResultSet rs= st.executeQuery("select * from employees"); 
      while( { 
Scroll to top