Ampli-JDBC - JDBC and Database Programming in Java Part I:...

Info iconThis preview shows pages 1–20. Sign up to view the full content.

View Full Document Right Arrow Icon
JDBC and Database Programming  in Java
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Part I: JDBC Overview
Background image of page 2
JDBC Goals SQL-Level 100% Pure Java Keep it simple High-performance Use strong, static typing wherever possible
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
JDBC Architecture Application JDBC Driver Java code calls JDBC library JDBC loads a  driver   Driver talks to a particular database Can have more than one driver -> more than one  database
Background image of page 4
JDBC Drivers Type I: “Bridge” Type II: “Native” Type III: “Middleware” Type IV: “Pure”
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Type I Drivers Use bridging technology Requires installation/configuration on client  machines Not good for Web e.g. JDBC ODBC Bridge
Background image of page 6
Type II Drivers Native API drivers Requires installation/configuration on client  machines Usually not thread-safe e.g. DB2 Driver, WebLogic drivers
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Type III Drivers Calls middleware server, usually on database  host Very flexible -- allows access to multiple  databases using one driver Only need to download one driver But it’s another server application to install and  maintain e.g. Symantec DBAnywhere
Background image of page 8
Type IV Drivers 100% Pure Java  Use Java networking libraries to talk directly to  database engines Only disadvantage: need to download a new  driver for each database engine e.g. Oracle, mSQL ,IBM DB2
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
JDBC Drivers (Fig.) JDBC Type I “Bridge” Type II “Native” Type III “Middleware” Type IV “Pure” ODBC ODBC Driver CLI (.lib) Middleware Server
Background image of page 10
Part III: JDBC APIs
Background image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
java.sql JDBC is implemented via classes in the java.sql  package
Background image of page 12
JDBC Object Classes DriverManager Loads, chooses drivers Driver connects to actual database Connection a series of SQL statements to and from the DB Statement a single SQL statement ResultSet the records returned from a Statement
Background image of page 13

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
JDBC Class Usage DriverManager Driver Connection Statement ResultSet
Background image of page 14
Registering a Driver statically load driver Class.forName(“foo.bar.MyDriver”);
Background image of page 15

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
DriverManager When a driver class is first loaded, it registers  itself with the DriverManager
Background image of page 16
Connection Connection getConnection (String url, String user, String password) Connects to given JDBC URL with given user  name and password Throws java.sql.SQLException returns a Connection object
Background image of page 17

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
JDBC URLs jdbc: subprotocol : source each driver has its own subprotocol each subprotocol has its own syntax for the  source jdbc:odbc: DataSource e.g.  jdbc:odbc:Northwind jdbc:db2:PROJWBT1","server","server"
Background image of page 18
Connection A Connection represents a session with a specific database. Within the context of a Connection, SQL statements are 
Background image of page 19

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 20
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 06/27/2011 for the course COMPUTER S 133 taught by Professor Andrewstrauss during the Spring '11 term at Bucks Community College.

Page1 / 54

Ampli-JDBC - JDBC and Database Programming in Java Part I:...

This preview shows document pages 1 - 20. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online