Java and Databases CS-328 Dick Steflik. Database Drivers Think of a database as just another device connected to your computer like other devices it has.

Slides:



Advertisements
Similar presentations
Connecting to Databases. relational databases tables and relations accessed using SQL database -specific functionality –transaction processing commit.
Advertisements

Introduction to Structured Query Language (SQL)
Distributed Application Development B. Ramamurthy.
Introduction to Structured Query Language (SQL)
1 C. Shahabi Application Programming for Relational Databases Cyrus Shahabi Computer Science Department University of Southern California
ASP.NET Database Connectivity I. 2 © UW Business School, University of Washington 2004 Outline Database Concepts SQL ASP.NET Database Connectivity.
CSE470 Software Engineering Fall Database Access through Java.
Introduction to Structured Query Language (SQL)
CSC 2720 Building Web Applications Database and SQL.
Advance Computer Programming Java Database Connectivity (JDBC) – In order to connect a Java application to a database, you need to use a JDBC driver. –
Getting connected.  Java application calls the JDBC library.  JDBC loads a driver which talks to the database.  We can change database engines without.
Java Database Connectivity (JDBC). Introduction Database –Collection of data DBMS –Database management system –Storing and organizing data SQL –Relational.
Session 5: Working with MySQL iNET Academy Open Source Web Development.
ASP.NET Programming with C# and SQL Server First Edition
© Wang Bin 2004 JDBC ----Java Database Connectivity.
CSE470 Software Engineering Fall Database Access through Java.
Beginning Databases with JDBC Mike Bradley Adapted from and notes by Kevin Parker, Ph.D.
Java Database Connectivity (JDBC) Introduction to JDBC JDBC is a simple API for connecting from Java applications to multiple databases. Lets you smoothly.
Database Programming in Java Corresponds with Chapter 32, 33.
PHP Programming with MySQL Slide 8-1 CHAPTER 8 Working with Databases and MySQL.
Introduction to SQL Steve Perry
Web Server Administration Chapter 7 Installing and Testing a Programming Environment.
Constraints  Constraints are used to enforce rules at table level.  Constraints prevent the deletion of a table if there is dependencies.  The following.
Designing and Developing WS B. Ramamurthy. Plans We will examine the resources available for development of JAX-WS based web services. We need an IDE,
Database: SQL and MySQL
CPS120: Introduction to Computer Science Lecture 19 Introduction to SQL.
File Processing Concepts – Field – combination of 1 or more characters that is the smallest unit of data to be accessed – Record – group of related fields.
7 1 Chapter 7 Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
Chapter 8 Databases.
Accessing Database using JDBC. JDBC Objectives Gain basic knowledge of Java JDBC Become familiar with the basics of interacting with a database using.
WEB/DB1 DATABASE PROGRAMMING 3JDBC by the ASU Scholars.
SQL: DDL. SQL Statements DDL - data definition language –Defining and modifying data structures (metadata): database, tables, views, etc. DML - data manipulation.
Chapter 25 Databases. Chapter Scope Database concepts Tables and queries SQL statements Managing data in a database Java Foundations, 3rd Edition, Lewis/DePasquale/Chase25.
6 1 Lecture 8: Introduction to Structured Query Language (SQL) J. S. Chou, P.E., Ph.D.
Java Database Connectivity (JDBC). Topics 1. The Vendor Variation Problem 2. SQL and Versions of JDBC 3. Creating an ODBC Data Source 4. Simple Database.
Topic 1: Introduction to SQL. SQL stands for Structured Query Language. SQL is a standard computer language for accessing and manipulating databases SQL.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
Web Server Administration Chapter 7 Installing and Testing a Programming Environment.
Chapter 9 Constraints. Chapter Objectives  Explain the purpose of constraints in a table  Distinguish among PRIMARY KEY, FOREIGN KEY, UNIQUE, CHECK,
JDBC CS 124. JDBC Java Database Connectivity Database Access Interface provides access to a relational database (by allowing SQL statements to be sent.
JDBC CHAPTER-2. JDBC - Java Database Connectivity. JDBC from Sun Microsystems provides API or Protocol to interact with different databases. With the.
12/6/2015B.Ramamurthy1 Java Database Connectivity B.Ramamurthy.
Java and Databases. JDBC Architecture Java Application JDBC API Data Base Drivers AccessSQL Server DB2InformixMySQLSybase.
DATABASE CONNECTIVITY TO MYSQL. Introduction =>A real life application needs to manipulate data stored in a Database. =>A database is a collection of.
CSI 3125, Preliminaries, page 1 JDBC. CSI 3125, Preliminaries, page 2 JDBC JDBC stands for Java Database Connectivity, which is a standard Java API (application.
Database Connectivity and Server-Side Scripting Chapter 12.
Database Connectivity with ASP.NET. 2 Introduction Web pages commonly used to: –Gather information stored on a Web server database Most server-side scripting.
Basics of JDBC Session 14.
ECMM6018 Enterprise Networking For Electronic Commerce Tutorial 6 CGI/Perl and databases.
JDBC Chapter 1 JDBC Introduction
Advanced Java Session 5 New York University School of Continuing and Professional Studies.
Ch. NoNameMarks 01AWT24 02Networking18 03JDBC20 04Swing18 05Servlet20 Advance Java Programming.
JDBC. SQL(Structured Query Language) is divided into 1.DDL(Data Definition Language) create db, create table, alter table, drop db or table 2.DML(Data.
7 1 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel 7.6 Advanced Select Queries SQL provides useful functions that.
In the Name Of Almighty Allah. Java Application Connection To Mysql Created by Hasibullah (Sahibzada) Kabul Computer Science Faculty Afghanistan.
LM 5 Introduction to SQL MISM 4135 Instructor: Dr. Lei Li.
JDBC. Database is used to store data permanently. These days almost all Applications needs database to store its data persistently. Below are the most.
A Presentation Presentation On JSP On JSP & Online Shopping Cart Online Shopping Cart.
1 Section 1 - Introduction to SQL u SQL is an abbreviation for Structured Query Language. u It is generally pronounced “Sequel” u SQL is a unified language.
Database: JDBC Overview
DEPTT. OF COMP. SC & APPLICATIONS
JDBC Database Management Database connectivity
Database JDBC Overview CS Programming Languages for Web Applications
JDBC.
JDBC – ODBC DRIVERS.
Java Database Connectivity
Introduction of Week 11 Return assignment 9-1 Collect assignment 10-1
ODBC and JDBC.
Intro to SQL CS-422 Dick Steflik.
Presentation transcript:

Java and Databases CS-328 Dick Steflik

Database Drivers Think of a database as just another device connected to your computer like other devices it has a driver program to relieves you of having to do low level programming to use the database the driver provides you with a high level api to the database

ODBC Open Data Base Connectivity Developed by Microsoft for the Windows platform as the way for Windows applications to access Microsoft databases (SQL Server, FoxPro, Access) Has become an industry standard Most data base vendors supply native, odbc, and jdbc drivers for their data base products

JDBC Architecture Java Application JDBC API Data Base Drivers AccessSQL Server DB2InformixMySQLSybase

JDBC Driver Types Type 1 – JDBC-ODBC Bridge Type 2 –Native API, partially java Type 3 –JDBC Network Driver, partially java Type 4 –100% Java

Type 1 Drivers Translate JDBC into ODBC and use Windows ODBC built in drivers ODBC must be set up on every client – driver must be physically on each machine for both java applications and applets –for server side servlets ODBC must be set up on web server driver sun.jdbc.odbc.JdbcOdbc provided by JavaSoft with JDK

Type 1 Driver (cont.) ClientJDBC- ODBC ODBCDB Vendor Library

Type 2 Drivers Converts JDBC to data base vendors native SQL calls like Type 1 drivers; requires installation of binaries on each client

Type 2 Drivers (cont.) Client JDBC Vendor Library DB

Type 3 Drivers Translates JDBC to a DBMS independent network protocol Typically talks directly with a middleware product which in turn talks to the RDBMS –Jaguar, DBAnywhere, SequeLink Most flexible driver type all java

Type 3 Drivers (cont.) ClientJDBC Vendor Middleware DB Tier 1Tier 2 Tier 3

Type 4 Drivers Converts JDBC directly to native API used by the RDBMS compiles into the application, applet or servlet; doesn’t require anything to be installed on client machine, except JVM handiest driver type

Type 4 Drivers (cont.) Client JDBCDB

Structured Query Language Developed by C. Date for Relational Data Base Management Systems (RDBMS) Simple Declarative Language –has no program control statements

SQL Two categories of commands –Data Manipulation Commands deal with: –RETRIEVING DATA –MAINTAINING DATA (ADDING, UPDATING,DELETING –Data Definition Commands DEAL WITH: –CREATING DATABASE OBJECTS (TABLES,VIEWS) –Object organization and attributes

Referential Integrity Rules to insure that table data stays accurate and accessible –rows in a table should be unique one column should contain no duplicate data primary key –column values cannot contain repeating groups or arrays –null is different than space and zero, 2 null values are not considered equal

Data Manipulation Commands Select - query and display data from a database Insert - a new row into a table Update - modify a column in a table Delete a row from a table

Select Select (column list) from (sources) where (conditions) order by (ocolumn list) column list - comma separated list of names of columns to be in output –Ex. ssn, lastname, firstname,gpa –can contain literals to be included in output Ex. Ssn,”~”,lastname,”~”,firstname sources - name(s) of table(s) to retrieve data from conditions (optional) - conditions for selections –lastname like “S%” –(lastname = “Steflik) and (firstname like “R%”) ocolumn list (optional)- list of columns that output should be ordered by Ex –select * from student –select lastname,fristname from student where gpa > 3.0 –select lastname,firstname from student order by lastname,firstname

Select - joined tables Two tables may be joined and viewed as a single data source is the both have a common column suppose we have 2 tables: Inventory and category and each has a column called catg_code In category catg_code is unique and is the primary key

Select - joined tables (cont.) P_noCatg_codeqtyCatg_codedescr Inventory Category join

Select - joined tables (cont.) To retrieve all of the part numbers and the name of the category to which the part belongs: –select inventory.p_no category.descr from inventroy, category –select a.p_no,” “,b.descr from a inventory, b category

Insert Add a row to a table –insert into category values(“IGN”,”Ignition System”) use jdbc execute Update method –ex. Stmt.executeUpdate(“insert into Category values(‘IGN’,’Ignition System’)”);

Update Modify an existing row in a table –update category set descr = “Ignition Subsystem” where catg_code = “IGN” Use jdbc executeUpdate method –String s = “ update category set descr = ‘Ignition Subsystem’ where catg_code = ‘IGN’ ”; –stmt.executeUpdate(s);

Delete Remove a row from a table –delete from category where catg_code = “IGN” remove the IGN category –delete from category where catg_code like “I%” remove all rows where catg_code starts with an “I”

Data Definition Commands Create table –add a table to a database Drop Table –remove a table from a database Alter Table –add or delete column(s)