DOC PREVIEW
USC CSCI 585 - session9-2004

This preview shows page 1-2-3-24-25-26 out of 26 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 26 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 26 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 26 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 26 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 26 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 26 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 26 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Application Programming for Relational DatabasesSlide 2OverviewClient server architectureSlide 5Slide 6Slide 7Database interaction in AccessSlide 9Slide 10Database interaction in JavaDatabase interaction in Embedded SQLJDBC: ArchitectureJDBC Architecture (Contd.)JDBC packageJDBC, different strategiesConnecting with JDBCConnecting to DB with JDBCSlide 19Slide 20Executing select queriesSlide 22Matching Java and SQL Data TypesExecuting update queriesSlide 25Mapping Objects1C. ShahabiApplication Programming for Relational DatabasesCyrus ShahabiComputer Science DepartmentUniversity of Southern [email protected]. ShahabiOverviewJDBC PackageConnecting to databases with JDBCExecuting select queriesExecuting update queries3C. ShahabiOverviewRole of an application: Update databases, extract info, through:User interfacesNon-interactive programsDevelopment tools (Access, Oracle):For user InterfacesProgramming languages (C, C++, Java,… ):User InterfacesNon-Interactive programsMore professional4C. ShahabiClient server architectureDatabase client:Connects to DB to manipulate data:Software packageApplication (incorporates software package)Client software:Provide general and specific capabilitiesOracle provides different capabilities as Sybase (its own methods, … )5C. ShahabiClient server architectureClient-Server architectures:2 tier3 tierLayer 1: user interfaceLayer 2:MiddlewareLayer 3:DB serverMiddleware:Server for clientClient for DB6C. ShahabiClient server architectureExample: Web interaction with DBLayer 1: web browserLayer 2: web server + cgi programLayer 3: DB server7C. ShahabiClient server architectureApplication layer (1):User interfacesOther utilities (report generator, …)Connect to middlewareCan connect to DB tooCan have more than one connectionCan issue SQL, or invoke methods in lower layers.Middleware layer (2):More reliable than user applications8C. ShahabiDatabase interaction in AccessDirect interaction with DBFor implementing applicationsNot professionalDeveloper edition: Generates stand alone applicationAccess application: GUI + “Visual Basic for Applications” code9C. ShahabiDatabase interaction in AccessConnection to DB through:Microsoft Jet database engine Support SQL accessDifferent file formatsOther Database Connectivity (ODBC)Support SQL DBsRequires driver for each DB server•Driver allows the program to become a client for DBClient behaves Independent of DB server10C. ShahabiDatabase interaction in AccessMaking data source available to ODBC application:Install ODBC driver managerInstall specific driver for a DB serverDatabase should be registered for ODBC managerHow application works with data source:Contacts driver manager to request for specific data sourceManager finds appropriate driver for the source11C. ShahabiDatabase interaction in JavaIncludes:Java.sql packageSet of classesSupports JDBC (java database connectivity?) strategy, independent of the DB serverDifference between JDBC and ODBC:JDBC driver manager is part of the application12C. ShahabiDatabase interaction in Embedded SQLExtension of a language (C++,C) with new commands:Void addEmployee( char *ssn, char *lastname, char *firstname) {•Exec SQL–Insert into customer( ssn, lastname, firstname ) values( :ssn, :lastname, :firstname )}Not legal language Compilation precedes by a translation preprocessor from embedded SQL into legal CAdvantages: ???Disadvantages:Not portable between database systemsDifficult debugging13C. ShahabiJDBC: ArchitectureFour Architectural Components:Application (initiates and terminates connections, submits SQL statements)Driver manager (load JDBC driver)Driver (connects to data source, transmits requests and returns/translates results and error codes)Data source (processes SQL statements)14C. ShahabiJDBC Architecture (Contd.)Four types of drivers:Bridge:Translates SQL commands into non-native API.Example: JDBC-ODBC bridge. Code for ODBC and JDBC driver needs to be available on each client.Direct translation to native API, non-Java driver:Translates SQL commands to native API of data source. Need OS-specific binary on each client.Network bridge:Send commands over the network to a middleware server that talks to the data source. Needs only small JDBC driver at each client.Direction translation to native API via Java driver:Converts JDBC calls directly to network protocol used by DBMS. Needs DBMS-specific Java driver at each client.15C. ShahabiJDBC packageCollection of interfaces and classes:DriverManager: Loads the driverDriver: creates a connectionConnection: represents a collectionDatabaseMetaData: information about the DB serverStatement: executing queriesPreparedStatement: precompiled and stored queryCallableStatment: execute SQL stored proceduresResultSet: results of execution of queriesResultSetMetaData: meta data for ResultSetReminder: Each JDBC package implements the interfaces for specific DB server16C. ShahabiJDBC, different strategiesStrategies to USE JDBCJDBC-ODBC bridgeCon: ODBC must be installedJDBC database clientCon: JDBC driver for each server must be availableJDBC middleware clientPro: Only one JDBC driver is requiredApplication does not need direct connection to DB (e.g., applet)17C. ShahabiConnecting with JDBC Database connection needs two piecesJDBC package driver class namePackage driver provide connection to DBURL of the databaseJDBC package designatorLocation of the serverDatabase designator, in form of:•Server name, Database name, Username, password, …•Properties18C. ShahabiConnecting to DB with JDBC Step 1: Find, open and load appropriate driver1. Class.forName( “sun.jdbc.odbc.JdbcOdbcDriver” );2. Class.forName( “oracle.thin.Driver” );3. Class.forName( “symantec.dbAnywhere.driver” );Or:4. DriverManager.registerDriver( your jdbc driver );Informs availability of the driver to “DriverManager” (registers the driver with DriverManager)(Example 1)19C. ShahabiConnecting to DB with JDBC Step 2: Make connection to the DBConnection conn = DriverManager( URL, Properties);•Properties: specific to the driverURL = Protocol + user•Protocol=


View Full Document

USC CSCI 585 - session9-2004

Download session9-2004
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view session9-2004 and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view session9-2004 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?