SlideShare a Scribd company logo
Prepared by-
Prince Paneliya (150120116047)
Guided by – Prof.Prashant Jani
Gandhinagar Institute of Technology
SUBJECT-AJAVA(2160707)
Creating JDBC connection
2
• JDBC: Java Database Connectivity kit
• Package: java.sql
• DriverManager: class for making connection to
databases
• Connection: interface for communicating with databases
once connection has been established.
• Other interfaces: Statement, ResultSet,
DatabaseMetaData, ResultSetMetaData,
SQLException, ….etc.
3
Connecting to Databases with JDBC
• JDBC-to-database communication path
Will discuss this path
using testdb.mdb
Textbook discusses this
path using testdb.mdb
Java Application
JDBC Driver Manager
JDBC/ODBC
bridge
Vendor
supplied
JDBC
driversODBC drivers
Database
4
• Register testdb.mdb with the ODBC Datasource Administer
on your PC. Instructions:
– Open Control Panel and select ODBC Data Sources
[32bit] (on XP under Administrative Tools). You will
get the window shown on the right. Click on Add.
5
– Select Microsoft Access Driver and then click on Finish.
You will get the window shown on the right.
– Provide a name for the data source, say TestDB.
– Click and Select and select testdb.mdb from file system
(picture on the next page)
6
– Then you see the picture on the right. Simply click on OK
and the registration is complete.
– Thereafter the database testdb.mdb is known as TestDB
to the ODBC Datasource Adminstrator.
– For JDBC, URL for the database is: jdbc:odbc:TestDB
7
• Register JDBC driver (sun.jdbc.odbc.JdbcOdbcDriver )
with DriverManager
– Method 1:
• set system property jdbc.drivers
System.setProperty("jdbc.drivers",
"sun.jdbc.odbc.JdbcOdbcDriver");
• At initialization, DriverManager loads all driver
classes referenced in jdbc.drivers
– Method 2: Load driver explicitely at any time
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
A call to forName("X") causes the class named X
to be initialized.
Java Application
JDBC Driver Manager
JDBC/ODBC
bridge
Vendor
supplied
JDBC
drivers
ODBC
Database
8
• Connection examples
– ConnectMe.java: register JDBC driver using the second
method
– ConnectMe1.java: register JDBC driver using the first
method
• Note. Examples (including testdb.mdb) in this topic are
packaged in the zip. See the code page
THANK YOU
9

More Related Content

PDF
Chapter6 database connectivity
PPTX
In Memory Unit Testing with Apache DbUnit
PPT
Java database connectivity with MYSQL
PPTX
My sql with java
PPTX
My Sql Work Bench
PPT
Introduction to MySQL - Part 1
PPTX
data manipulation language
Chapter6 database connectivity
In Memory Unit Testing with Apache DbUnit
Java database connectivity with MYSQL
My sql with java
My Sql Work Bench
Introduction to MySQL - Part 1
data manipulation language

Similar to creating JDBC connection (20)

PPT
java jdbc connection
PDF
jdbc
PPT
Jdbc
PPT
PPT
Jdbc drivers
PPT
Chap3 3 12
PPT
JDBC.ppt
PPT
Jdbc slide for beginers
PPT
Jdbc sasidhar
PDF
Java Database Connectivity (Advanced programming)
PPT
Final Database Connectivity in JAVA.ppt
PDF
JDBC Presentation with JAVA code Examples.pdf
PDF
Chapter 5 JDBC.pdf for stufent of computer andtudent It s
PPTX
21CS642 Module 5 JDBC PPT.pptx VI SEM CSE Students
PPTX
Advanced JAVA
DOC
jdbc document
PPTX
1. java database connectivity (jdbc)
PPT
Basic Java Database Connectivity(JDBC)
PPT
open data base connectivity and java database connectivity
java jdbc connection
jdbc
Jdbc
Jdbc drivers
Chap3 3 12
JDBC.ppt
Jdbc slide for beginers
Jdbc sasidhar
Java Database Connectivity (Advanced programming)
Final Database Connectivity in JAVA.ppt
JDBC Presentation with JAVA code Examples.pdf
Chapter 5 JDBC.pdf for stufent of computer andtudent It s
21CS642 Module 5 JDBC PPT.pptx VI SEM CSE Students
Advanced JAVA
jdbc document
1. java database connectivity (jdbc)
Basic Java Database Connectivity(JDBC)
open data base connectivity and java database connectivity
Ad

More from Paneliya Prince (20)

PPTX
140120107044 ins ala.ppt
DOCX
To create a web service
PPT
Session and state management
PPT
Master pages
DOCX
Master page
DOCX
Managing states
PPT
Introduction to ado.net
DOCX
Grid view control
PPTX
Asp.net validation
PPT
Asp.net control
DOC
Wt oep visiting card
DOCX
SE OEP online car service booking
PPTX
creating jdbc connection
PPTX
processing control input
PPT
static dictionary technique
DOCX
Ajava oep
DOC
Ajava oep shopping application
PPT
creating jdbc connection
PPTX
PPTX
static dictionary
140120107044 ins ala.ppt
To create a web service
Session and state management
Master pages
Master page
Managing states
Introduction to ado.net
Grid view control
Asp.net validation
Asp.net control
Wt oep visiting card
SE OEP online car service booking
creating jdbc connection
processing control input
static dictionary technique
Ajava oep
Ajava oep shopping application
creating jdbc connection
static dictionary
Ad

Recently uploaded (20)

PPTX
web development for engineering and engineering
PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
PPT
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS
PDF
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PPTX
CH1 Production IntroductoryConcepts.pptx
PPTX
Lecture Notes Electrical Wiring System Components
PPTX
Sustainable Sites - Green Building Construction
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PPTX
Welding lecture in detail for understanding
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PPTX
Construction Project Organization Group 2.pptx
PPT
Project quality management in manufacturing
PDF
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
PPTX
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
web development for engineering and engineering
Automation-in-Manufacturing-Chapter-Introduction.pdf
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
Foundation to blockchain - A guide to Blockchain Tech
CH1 Production IntroductoryConcepts.pptx
Lecture Notes Electrical Wiring System Components
Sustainable Sites - Green Building Construction
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
Welding lecture in detail for understanding
Operating System & Kernel Study Guide-1 - converted.pdf
Construction Project Organization Group 2.pptx
Project quality management in manufacturing
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
CYBER-CRIMES AND SECURITY A guide to understanding
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...

creating JDBC connection

  • 1. Prepared by- Prince Paneliya (150120116047) Guided by – Prof.Prashant Jani Gandhinagar Institute of Technology SUBJECT-AJAVA(2160707) Creating JDBC connection
  • 2. 2 • JDBC: Java Database Connectivity kit • Package: java.sql • DriverManager: class for making connection to databases • Connection: interface for communicating with databases once connection has been established. • Other interfaces: Statement, ResultSet, DatabaseMetaData, ResultSetMetaData, SQLException, ….etc.
  • 3. 3 Connecting to Databases with JDBC • JDBC-to-database communication path Will discuss this path using testdb.mdb Textbook discusses this path using testdb.mdb Java Application JDBC Driver Manager JDBC/ODBC bridge Vendor supplied JDBC driversODBC drivers Database
  • 4. 4 • Register testdb.mdb with the ODBC Datasource Administer on your PC. Instructions: – Open Control Panel and select ODBC Data Sources [32bit] (on XP under Administrative Tools). You will get the window shown on the right. Click on Add.
  • 5. 5 – Select Microsoft Access Driver and then click on Finish. You will get the window shown on the right. – Provide a name for the data source, say TestDB. – Click and Select and select testdb.mdb from file system (picture on the next page)
  • 6. 6 – Then you see the picture on the right. Simply click on OK and the registration is complete. – Thereafter the database testdb.mdb is known as TestDB to the ODBC Datasource Adminstrator. – For JDBC, URL for the database is: jdbc:odbc:TestDB
  • 7. 7 • Register JDBC driver (sun.jdbc.odbc.JdbcOdbcDriver ) with DriverManager – Method 1: • set system property jdbc.drivers System.setProperty("jdbc.drivers", "sun.jdbc.odbc.JdbcOdbcDriver"); • At initialization, DriverManager loads all driver classes referenced in jdbc.drivers – Method 2: Load driver explicitely at any time Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); A call to forName("X") causes the class named X to be initialized. Java Application JDBC Driver Manager JDBC/ODBC bridge Vendor supplied JDBC drivers ODBC Database
  • 8. 8 • Connection examples – ConnectMe.java: register JDBC driver using the second method – ConnectMe1.java: register JDBC driver using the first method • Note. Examples (including testdb.mdb) in this topic are packaged in the zip. See the code page