Presentation is loading. Please wait.

Presentation is loading. Please wait.

Java JDBC API. A Java API To Access almost any kind of tabular data To Access almost any kind of tabular data Trademarked (not an acronym) Trademarked.

Similar presentations


Presentation on theme: "Java JDBC API. A Java API To Access almost any kind of tabular data To Access almost any kind of tabular data Trademarked (not an acronym) Trademarked."— Presentation transcript:

1 Java JDBC API

2 A Java API To Access almost any kind of tabular data To Access almost any kind of tabular data Trademarked (not an acronym) Trademarked (not an acronym) A set of classes and interfaces written in Java A set of classes and interfaces written in Java Supports all dialects of SQL Supports all dialects of SQL Goes beyond SQL: makes it possible to interact with other kinds of data sources such as files containing tabular data Goes beyond SQL: makes it possible to interact with other kinds of data sources such as files containing tabular data

3 Features Can access almost any data source Can access almost any data source Can run on any platform with a Java Virtual Machine Can run on any platform with a Java Virtual Machine

4 Examples Possible to publish a web page containing an applet that uses information obtained from a remote data source Possible to publish a web page containing an applet that uses information obtained from a remote data source A company can connect all employees (using a collection of Windows, Mac, UNIX machines) to internal databases through an intranet A company can connect all employees (using a collection of Windows, Mac, UNIX machines) to internal databases through an intranet One can write a single program to send SQL statements to, e.g., an Oracle DB, a Sybase DB, and IBM DB2 DB. One can write a single program to send SQL statements to, e.g., an Oracle DB, a Sybase DB, and IBM DB2 DB.

5 What Does the Java API Do? 1. Establish a connection with a data source 2. Send queries and update statements to the data source 3. Process the results

6 Code Snippet Connection con = DriverManager.getConnection( “jdbc:oracle:thin@cs.gonzaga.edu:1521:basicdb”, “jdbc:oracle:thin@cs.gonzaga.edu:1521:basicdb”, “myLogin”, “myPasswd”); “myLogin”, “myPasswd”); Statement stmt = con.createStatement(); ResultSet rs = stmt.executeQuery(“select lname from employee”); while (rs.next()) System.out.println(rs.getString(1)); System.out.println(rs.getString(1)); stmt.close(); stmt.close();

7 JDBC is similar to ODBC An API for accessing data stores An API for accessing data stores But But It is partly written in C and so loses Java’s portability, security It is partly written in C and so loses Java’s portability, security JDBC is simpler than ODBC JDBC is simpler than ODBC JDBC is written in Java for Java applications JDBC is written in Java for Java applications

8 JDBC Application (2-Tier Model) Java Application JDBC DBMS

9 JDBC Applet (3-Tier Model) Browser (Java Applet) Java Program JDBC DBMS

10 Java Strengths Java is portable Java is portable Java is object-oriented Java is object-oriented Large library of classes and interfaces Large library of classes and interfaces Examples Examples Applets Applets Graphics Graphics Sql Sql Security Security

11 Continued Java makes it easier to write correct code Java makes it easier to write correct code Automatic garbage collection Automatic garbage collection No pointers No pointers Strong typing Strong typing Exception handling Exception handling Simplicity (no templates or multiple inheritance) Simplicity (no templates or multiple inheritance)

12 Continued Security Features Security Features Memory layout is determined at run-time (unlike c/c++ where compiler makes layout decisions) Memory layout is determined at run-time (unlike c/c++ where compiler makes layout decisions) Therefore, a programmer can’t look at a class def. and figure out how it might be laid out Therefore, a programmer can’t look at a class def. and figure out how it might be laid out JVM checks incoming code for forged pointers, access restrictions JVM checks incoming code for forged pointers, access restrictions Classes from across the network can’t be substituted for built-in classes Classes from across the network can’t be substituted for built-in classes Built-in classes can’t accidentally reference classes from across the network. Built-in classes can’t accidentally reference classes from across the network.


Download ppt "Java JDBC API. A Java API To Access almost any kind of tabular data To Access almost any kind of tabular data Trademarked (not an acronym) Trademarked."

Similar presentations


Ads by Google