By
M.YAMUNA DEVI
CSE Department , 10AG1AO568
CONTENTS
Introduction.
Importance of databases.
Jdbc.
Jdbc api,architecture.
Jdbc key components with steps.
Overvie...
Why Java??
>Write once, run anywhere
> Multiple client and server platforms
>

Database independence
> Java can access any...
Importance of databases:
we can store our data permanently by using file concept. If we are using file
concept we have som...
In database software the data will be stored permanent it supports query
language.
it takes less time for inserting ,del...


>
odbc is a standard or open application programming
interface (API) for accessing a database.



Handles these reques...
>

Tasks of JDBC:
1) establishes a connection with a database
2) sends SQL statements
3) processes the results
JDBC key components:
Driver Manager , Connection , Statement , Result Set
• Driver Manager handles communication with diff...
Four steps in creating a database
application
Step 1: load a database driver
Step 2: make a database connection
Step 3: cr...
Step 1: Loading a Driver
•Loading a driver requires class name of the driver
•For JDBC-ODBC driver the class name is: sun....
Step 2: Opening a Database Connection
• Connection is an interface defined in java.sql package.
A Connection object repres...
Step 3: Creating Statement & executing SQL
Statements
Connection objects can be used to create statement
objects.
Statemen...
Step4:Retrieving the data from db
Individual column fields can be retrieved using
the get methods within the ResultSet.
St...
Connect

Query

Process
results

Close
Connect

Register the driver

Query

Connect to the database

Process
results

Close
Connect

Query

Create a statement

Process
results

Query the database

Close
Connect

Query
Step through the results

Process
results

Close

Assign results to Java
variables
Connect

Query
Close the result set
Process
results

Close the statement

Close

Close the connection
Advantages
1) Can read any database if proper drivers are installed.
2) Query and Stored procedure supported.

Disadvantag...
Conclusion
JDBC provides API or Protocol to interact with different databases.
With the help of JDBC driver we can connect...
References
http://www.oracle.com/technetork/java/javase/jdbc/index.h
tml.
http://docs.oracle.com/javase/tutorial/jdbc/
htt...
Thank You !!!
ANY QUERIES?
Upcoming SlideShare
Loading in …5
×

Jdbc

573
-1

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
573
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
55
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Jdbc

  1. 1. By M.YAMUNA DEVI CSE Department , 10AG1AO568
  2. 2. CONTENTS Introduction. Importance of databases. Jdbc. Jdbc api,architecture. Jdbc key components with steps. Overview of querying a db with stages. Advantages and disadvantages. Conclusion.
  3. 3. Why Java?? >Write once, run anywhere > Multiple client and server platforms > Database independence > Java can access any database vendor > Ease of administration
  4. 4. Importance of databases: we can store our data permanently by using file concept. If we are using file concept we have some drawbacks. •.if we want to use file concept we need to know about IO package concept and can store small amount of data. •Inserting , deleting, updating in files it takes more time. •It does not support query language •In files we store data in the form of text or objects. to overcome all these problems we go for database software
  5. 5. In database software the data will be stored permanent it supports query language. it takes less time for inserting ,deleting ,updating ,retrieve . in database s/w the data will be stored in table storing in the form of rows and columns. some of the database software are 1)oracle 2)mysql 3)sql server 4)DB2
  6. 6.  > odbc is a standard or open application programming interface (API) for accessing a database.  Handles these requests and converts it into a request understandable by an individual database system.  Java API for connecting programs written in Java to the data in relational databases  The standard defined by Sun Microsystems, allowing individual providers to implement and extend the standard with their own JDBC drivers. 
  7. 7. > Tasks of JDBC: 1) establishes a connection with a database 2) sends SQL statements 3) processes the results
  8. 8. JDBC key components: Driver Manager , Connection , Statement , Result Set • Driver Manager handles communication with different drivers that conform to JDBC Driver API • The static class Driver Manager manages the loaded drivers and contains methods for accessing connections to the databases JDBC Driver Manager
  9. 9. Four steps in creating a database application Step 1: load a database driver Step 2: make a database connection Step 3: create and execute SQL statement Step 4: process the result set , if necessary
  10. 10. Step 1: Loading a Driver •Loading a driver requires class name of the driver •For JDBC-ODBC driver the class name is: sun. jdbc.Odbc .JdbcOdbcDriver try { Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver”); } •The class definition of the driver is loaded using forName static method of the class Class (in package java.lang ) • catch (Exception e) { System.out.println(e); }
  11. 11. Step 2: Opening a Database Connection • Connection is an interface defined in java.sql package. A Connection object represents a connection with the database. The interface has methods to create statements which can be used to manipulate the database. Connection cn=DriverManager.getConnection(“jdbc:odbc:ora”,”yamu na”,”ace”);
  12. 12. Step 3: Creating Statement & executing SQL Statements Connection objects can be used to create statement objects. Statement = cn.createStatement(); Statement is an interface that contains methods for executing SQL queries Like executeUpdate()-insert,delet,update For selection we refer executeQuery()
  13. 13. Step4:Retrieving the data from db Individual column fields can be retrieved using the get methods within the ResultSet. String qry=“select *from employs”; ResultSet rs=stmt.executeQuery(qry); String id=rs.getString(1); Resultset is the return type of executeQuery(). Columns may be specified by their field name or by their index.
  14. 14. Connect Query Process results Close
  15. 15. Connect Register the driver Query Connect to the database Process results Close
  16. 16. Connect Query Create a statement Process results Query the database Close
  17. 17. Connect Query Step through the results Process results Close Assign results to Java variables
  18. 18. Connect Query Close the result set Process results Close the statement Close Close the connection
  19. 19. Advantages 1) Can read any database if proper drivers are installed. 2) Query and Stored procedure supported. Disadvantages 1) Correct drivers need to be deployed for each type of database 2) Cannot update or insert multiple tables with sequence. ( Sequence is always random)
  20. 20. Conclusion JDBC provides API or Protocol to interact with different databases. With the help of JDBC driver we can connect with different types of databases This technology is an API for the java programming language that defines how a client may access a database. It provides methods for querying and updating data in a database. JDBC is oriented towards relational databases. A JDBC-to-ODBC bridge enables connections to any ODBCaccessible data source in the JVM host environment.
  21. 21. References http://www.oracle.com/technetork/java/javase/jdbc/index.h tml. http://docs.oracle.com/javase/tutorial/jdbc/ http://www.webopedia.com/TERM/J/JDBC.html http://infolab.stanford.edu/~ullman/fcdb/oracle/orjdbc.html
  22. 22. Thank You !!!
  23. 23. ANY QUERIES?
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×