SlideShare une entreprise Scribd logo
1  sur  22
 JDBC – provides an interface to
Relational Data Sources.
 JDBC library provides the means for
executing SQL statements to access and
operate on a relational database.
 JDBC library is implemented in the
java.sql package
 Set of classes and interfaces that
provide a uniform API for access to
broad range of databases.
 JDBC:
 establishes a
connection with a
database
 sends SQL statements .
 processes the results.
Java Application
JDBC
Access
Database
Oracle
Database
Sybase
Database
 JDBC’s DEsIGn Is vEry sImIlar to tHE
design of ODBC.
 Driver Manager
 Loads database drivers, and
manages the connection between
the application and the driver.
 Driver
 Translates API calls into
operations for a specific data
source
 Statement
 An SQL Statement to perform a
query or update operation.
 Metadata
 Information about returned
data, the database and the driver.
 ResultSet
 Logical set of columns and rows
returned by executing an SQL
statement (resulting tuples).
Driver
Manager
Connection Statement ResultSet
Driver
Database
Creates Creates Creates
SQL
Result
(tuples)
Establish
Link to DB
 Java Application
talks directly to
the database.
 Accomplished
through the JDBC
driver which
sends commands
directly to the
database.
 Results sent back
directly to the
application.
 A JDBC driver sits
on the client
Application Space
Java Application
JDBC Driver
Database
SQL
Command
Result
Set
 JDBC driver sends
commands to a middle
tier, which in turn
sends commands to
database.
 middle tier can
provide
• a higher-level
API, not just SQL
• control over
database access
• performance
advantages
ex. load
balancing and
caching
frequently accessed
data
Application Space
Java Application
JDBC Driver
Database
SQL
Command
Result
Set
Application Server
(middle-tier)
Proprietary
Protocol
Application Space
Java Application
JDBC Driver
Database
SQL
Command
Result
Set
Application Server
(middle-tier)
Proprietary
Protocol
Pros:
flexible: can change one
part without
affecting others
can connect to different
databases without
changing code
specialization:
presentation / business
logic /
data management
can cache queries
can implement proxies
and firewalls
Cons:
higher complexity
higher maintenance
lower network
efficiency
JDBC API, a purely
java-based API.
JDBC Driver Manager
which communicates
with vendor specific
drivers that perform
real communication
with the database.
Java Application
JDBC Driver Manager
JDBC/ODBC
Bridge
Vendor
Supplied
JDBC
Driver
ODBC
Driver
 JDBC-ODBC bridge
plus ODBC driver
basically converts
JDBC calls to
mICrosoFt’s opEn
database
connectivity(ODBC).
 As with JDBC , ODBC
programming
interface that you
can use to access
Application Space
Java Application
JDBC – ODBC Bridge
Database
SQL
Command
Result
Set
ODBC Driver
Proprietary
Protocol
Advantages:
• Can be useful for databases
where other methods not
available (e.g., MSAccess).
Disadvantages:
• Client computer needs to be
configured with ODBC driver and
ODBC instance which specifies
database server and other
SQL Type Java Type
CHAR String
VARCHAR String
LONGVARCHAR String
NUMERIC
java.Math.BigDecimal
DECIMAL
java.Math.BigDecimal
BIT boolean
TINYINT int
SMALLINT int
INTEGER int
BIGINT long
REAL float
FLOAT double
DOUBLE double
BINARY byte[]
VARBINARY byte[]
DATE java.sql.Date
1. Importing Packages .
2. Registering the JDBC Drivers .
3. Opening a Connection to a
Database .
4. Creating a Statement Object.
5. Executing a Query and
Returning a Result Set Object .
6. Processing the Result Set .
7. Closing the Result Set and
Statement Objects .
// Program name: jdbc_smvdu.java
//Import packages
import java.sql.*; // JDBC
packages
import java.math.*;
import java.io.*;
import oracle.jdbc.driver.*;
class jdbc_smvdu {
public static void main (String args [])
throws SQLException {
// Load Odbc driver
Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver”);
//Prompt user for username and password
String user;
String password;
user = readEntry
("username: ");
password = readEntry
("password: ");
// Connect to the local database
Connection conn =
DriverManager.getConnection
Statement stmnt=
conn.createStatement();
String st= “sElECt FIrst namE, aGE
From EmployEE wHErE ID= 20 ”;
ResultSet rset =
stmnt.executeQuery (s);
// Print query results
while (rset.next ())
System.out.println (rset.getString
(1)+" "+ rset.getString(2));
// close the result set, statement, and the
connection
rset.close( );
stmnt.close( );
conn.close( );
}
Rajesh   jdbc

Contenu connexe

Tendances (20)

Ajp notes-chapter-05
Ajp notes-chapter-05Ajp notes-chapter-05
Ajp notes-chapter-05
 
Jdbc_ravi_2016
Jdbc_ravi_2016Jdbc_ravi_2016
Jdbc_ravi_2016
 
Jdbc drivers
Jdbc driversJdbc drivers
Jdbc drivers
 
Database and Java Database Connectivity
Database and Java Database ConnectivityDatabase and Java Database Connectivity
Database and Java Database Connectivity
 
Java- JDBC- Mazenet Solution
Java- JDBC- Mazenet SolutionJava- JDBC- Mazenet Solution
Java- JDBC- Mazenet Solution
 
java Jdbc
java Jdbc java Jdbc
java Jdbc
 
Java DataBase Connectivity API (JDBC API)
Java DataBase Connectivity API (JDBC API)Java DataBase Connectivity API (JDBC API)
Java DataBase Connectivity API (JDBC API)
 
Overview Of JDBC
Overview Of JDBCOverview Of JDBC
Overview Of JDBC
 
Jdbc Ppt
Jdbc PptJdbc Ppt
Jdbc Ppt
 
Jdbc
JdbcJdbc
Jdbc
 
JDBC Architecture and Drivers
JDBC Architecture and DriversJDBC Architecture and Drivers
JDBC Architecture and Drivers
 
Jdbc complete
Jdbc completeJdbc complete
Jdbc complete
 
Jdbc slide for beginers
Jdbc slide for beginersJdbc slide for beginers
Jdbc slide for beginers
 
JDBC
JDBCJDBC
JDBC
 
Basic Java Database Connectivity(JDBC)
Basic Java Database Connectivity(JDBC)Basic Java Database Connectivity(JDBC)
Basic Java Database Connectivity(JDBC)
 
JDBC: java DataBase connectivity
JDBC: java DataBase connectivityJDBC: java DataBase connectivity
JDBC: java DataBase connectivity
 
JDBC,Types of JDBC,Resultset, statements,PreparedStatement,CallableStatements...
JDBC,Types of JDBC,Resultset, statements,PreparedStatement,CallableStatements...JDBC,Types of JDBC,Resultset, statements,PreparedStatement,CallableStatements...
JDBC,Types of JDBC,Resultset, statements,PreparedStatement,CallableStatements...
 
Jdbc
JdbcJdbc
Jdbc
 
JDBC Connectivity Model
JDBC Connectivity ModelJDBC Connectivity Model
JDBC Connectivity Model
 
Java database connectivity
Java database connectivityJava database connectivity
Java database connectivity
 

Similaire à Rajesh jdbc

JDBC with MySQL.pdf
JDBC with MySQL.pdfJDBC with MySQL.pdf
JDBC with MySQL.pdfArumugam90
 
JDBC with MySQL.pdf
JDBC with MySQL.pdfJDBC with MySQL.pdf
JDBC with MySQL.pdfArumugam90
 
Java database connectivity with MySql
Java database connectivity with MySqlJava database connectivity with MySql
Java database connectivity with MySqlDhyey Dattani
 
Java database connectivity with MySql
Java database connectivity with MySqlJava database connectivity with MySql
Java database connectivity with MySqlDhyey Dattani
 
JDBC : Java Database Connectivity
JDBC : Java Database Connectivity JDBC : Java Database Connectivity
JDBC : Java Database Connectivity DevAdnani
 
Unit 5-jdbc2
Unit 5-jdbc2Unit 5-jdbc2
Unit 5-jdbc2msafad
 
JDBC java for learning java for learn.ppt
JDBC java for learning java for learn.pptJDBC java for learning java for learn.ppt
JDBC java for learning java for learn.pptkingkolju
 
Java Database Connectivity
Java Database ConnectivityJava Database Connectivity
Java Database Connectivitybackdoor
 
Java Database Connectivity (JDBC)
Java Database Connectivity (JDBC)Java Database Connectivity (JDBC)
Java Database Connectivity (JDBC)Pooja Talreja
 
jdbc Java Database Connectivity ujjwal matoliya jdbc.pptx
 jdbc Java Database Connectivity ujjwal matoliya jdbc.pptx jdbc Java Database Connectivity ujjwal matoliya jdbc.pptx
jdbc Java Database Connectivity ujjwal matoliya jdbc.pptxujjwalmatoliya
 
Chapter_4_-_JDBC[1].pptx
Chapter_4_-_JDBC[1].pptxChapter_4_-_JDBC[1].pptx
Chapter_4_-_JDBC[1].pptxBachaSirata
 
jdbc-130913021409-phpapp01000988www.pptx
jdbc-130913021409-phpapp01000988www.pptxjdbc-130913021409-phpapp01000988www.pptx
jdbc-130913021409-phpapp01000988www.pptxssuser8878c1
 
chapter 5 java.pptx
chapter 5  java.pptxchapter 5  java.pptx
chapter 5 java.pptxBekiTube
 
JDBC Presentation with JAVA code Examples.pdf
JDBC Presentation with JAVA code Examples.pdfJDBC Presentation with JAVA code Examples.pdf
JDBC Presentation with JAVA code Examples.pdfssuser8878c1
 

Similaire à Rajesh jdbc (20)

Jdbc introduction
Jdbc introductionJdbc introduction
Jdbc introduction
 
JDBC with MySQL.pdf
JDBC with MySQL.pdfJDBC with MySQL.pdf
JDBC with MySQL.pdf
 
JDBC with MySQL.pdf
JDBC with MySQL.pdfJDBC with MySQL.pdf
JDBC with MySQL.pdf
 
Java database connectivity with MySql
Java database connectivity with MySqlJava database connectivity with MySql
Java database connectivity with MySql
 
Java database connectivity with MySql
Java database connectivity with MySqlJava database connectivity with MySql
Java database connectivity with MySql
 
Jdbc ppt
Jdbc pptJdbc ppt
Jdbc ppt
 
JDBC : Java Database Connectivity
JDBC : Java Database Connectivity JDBC : Java Database Connectivity
JDBC : Java Database Connectivity
 
Unit 5-jdbc2
Unit 5-jdbc2Unit 5-jdbc2
Unit 5-jdbc2
 
JDBC java for learning java for learn.ppt
JDBC java for learning java for learn.pptJDBC java for learning java for learn.ppt
JDBC java for learning java for learn.ppt
 
Java Database Connectivity
Java Database ConnectivityJava Database Connectivity
Java Database Connectivity
 
Java Database Connectivity (JDBC)
Java Database Connectivity (JDBC)Java Database Connectivity (JDBC)
Java Database Connectivity (JDBC)
 
jdbc Java Database Connectivity ujjwal matoliya jdbc.pptx
 jdbc Java Database Connectivity ujjwal matoliya jdbc.pptx jdbc Java Database Connectivity ujjwal matoliya jdbc.pptx
jdbc Java Database Connectivity ujjwal matoliya jdbc.pptx
 
Chapter_4_-_JDBC[1].pptx
Chapter_4_-_JDBC[1].pptxChapter_4_-_JDBC[1].pptx
Chapter_4_-_JDBC[1].pptx
 
Core jdbc basics
Core jdbc basicsCore jdbc basics
Core jdbc basics
 
jdbc
jdbcjdbc
jdbc
 
3 jdbc
3 jdbc3 jdbc
3 jdbc
 
jdbc-130913021409-phpapp01000988www.pptx
jdbc-130913021409-phpapp01000988www.pptxjdbc-130913021409-phpapp01000988www.pptx
jdbc-130913021409-phpapp01000988www.pptx
 
chapter 5 java.pptx
chapter 5  java.pptxchapter 5  java.pptx
chapter 5 java.pptx
 
Assignment#10
Assignment#10Assignment#10
Assignment#10
 
JDBC Presentation with JAVA code Examples.pdf
JDBC Presentation with JAVA code Examples.pdfJDBC Presentation with JAVA code Examples.pdf
JDBC Presentation with JAVA code Examples.pdf
 

Dernier

Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Bhuvaneswari Subramani
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 

Dernier (20)

Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 

Rajesh jdbc

  • 1.
  • 2.  JDBC – provides an interface to Relational Data Sources.  JDBC library provides the means for executing SQL statements to access and operate on a relational database.  JDBC library is implemented in the java.sql package  Set of classes and interfaces that provide a uniform API for access to broad range of databases.
  • 3.  JDBC:  establishes a connection with a database  sends SQL statements .  processes the results.
  • 5.  JDBC’s DEsIGn Is vEry sImIlar to tHE design of ODBC.  Driver Manager  Loads database drivers, and manages the connection between the application and the driver.  Driver  Translates API calls into operations for a specific data source
  • 6.  Statement  An SQL Statement to perform a query or update operation.  Metadata  Information about returned data, the database and the driver.  ResultSet  Logical set of columns and rows returned by executing an SQL statement (resulting tuples).
  • 7. Driver Manager Connection Statement ResultSet Driver Database Creates Creates Creates SQL Result (tuples) Establish Link to DB
  • 8.  Java Application talks directly to the database.  Accomplished through the JDBC driver which sends commands directly to the database.  Results sent back directly to the application.  A JDBC driver sits on the client Application Space Java Application JDBC Driver Database SQL Command Result Set
  • 9.  JDBC driver sends commands to a middle tier, which in turn sends commands to database.  middle tier can provide • a higher-level API, not just SQL • control over database access • performance advantages ex. load balancing and caching frequently accessed data Application Space Java Application JDBC Driver Database SQL Command Result Set Application Server (middle-tier) Proprietary Protocol
  • 10. Application Space Java Application JDBC Driver Database SQL Command Result Set Application Server (middle-tier) Proprietary Protocol Pros: flexible: can change one part without affecting others can connect to different databases without changing code specialization: presentation / business logic / data management can cache queries can implement proxies and firewalls Cons: higher complexity higher maintenance lower network efficiency
  • 11. JDBC API, a purely java-based API. JDBC Driver Manager which communicates with vendor specific drivers that perform real communication with the database. Java Application JDBC Driver Manager JDBC/ODBC Bridge Vendor Supplied JDBC Driver ODBC Driver
  • 12.  JDBC-ODBC bridge plus ODBC driver basically converts JDBC calls to mICrosoFt’s opEn database connectivity(ODBC).  As with JDBC , ODBC programming interface that you can use to access Application Space Java Application JDBC – ODBC Bridge Database SQL Command Result Set ODBC Driver Proprietary Protocol
  • 13. Advantages: • Can be useful for databases where other methods not available (e.g., MSAccess). Disadvantages: • Client computer needs to be configured with ODBC driver and ODBC instance which specifies database server and other
  • 14. SQL Type Java Type CHAR String VARCHAR String LONGVARCHAR String NUMERIC java.Math.BigDecimal DECIMAL java.Math.BigDecimal BIT boolean TINYINT int SMALLINT int INTEGER int BIGINT long REAL float FLOAT double DOUBLE double BINARY byte[] VARBINARY byte[] DATE java.sql.Date
  • 15. 1. Importing Packages . 2. Registering the JDBC Drivers . 3. Opening a Connection to a Database . 4. Creating a Statement Object. 5. Executing a Query and Returning a Result Set Object . 6. Processing the Result Set . 7. Closing the Result Set and Statement Objects .
  • 16. // Program name: jdbc_smvdu.java //Import packages import java.sql.*; // JDBC packages import java.math.*; import java.io.*; import oracle.jdbc.driver.*;
  • 17. class jdbc_smvdu { public static void main (String args []) throws SQLException { // Load Odbc driver Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver”);
  • 18. //Prompt user for username and password String user; String password; user = readEntry ("username: "); password = readEntry ("password: "); // Connect to the local database Connection conn = DriverManager.getConnection
  • 19. Statement stmnt= conn.createStatement(); String st= “sElECt FIrst namE, aGE From EmployEE wHErE ID= 20 ”;
  • 20. ResultSet rset = stmnt.executeQuery (s); // Print query results while (rset.next ()) System.out.println (rset.getString (1)+" "+ rset.getString(2));
  • 21. // close the result set, statement, and the connection rset.close( ); stmnt.close( ); conn.close( ); }