DataBases and SQL INFSY 547 Spring 2007. Course Wrap Up April 12: Complete Work on Servlets Review of Team Projects Close of Portfolio Work April 19:

Slides:



Advertisements
Similar presentations
 Pearson Education, Inc. All rights reserved Accessing Databases with JDBC.
Advertisements

Distributed Application Development B. Ramamurthy.
Fundamentals, Design, and Implementation, 9/e Chapter 14 JDBC, Java Server Pages, and MySQL.
1 C. Shahabi Application Programming for Relational Databases Cyrus Shahabi Computer Science Department University of Southern California
DT228/3 Web Development Databases. Database Almost all web application on the net access a database e.g. shopping sites, message boards, search engines.
CSE470 Software Engineering Fall Database Access through Java.
CSC 2720 Building Web Applications Database and SQL.
Java database Programming JDBC Trademarked name of a Java API that supports Java programs that access relational databases Stand for Java DataBase Connectivity.
1 Foundations of Software Design Lecture 27: Java Database Programming Marti Hearst Fall 2002.
Chapter 7 Managing Data Sources. ASP.NET 2.0, Third Edition2.
JDBC / ODBC JDBC is the java API that facilitate interaction of a java application with the DBMS. FIRST APPROACH:
Introduction to JDBC (Java Database Connectivity).
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.
CSCI 6962: Server-side Design and Programming
Java Database Connectivity (JDBC). Introduction Database –Collection of data DBMS –Database management system –Storing and organizing data SQL –Relational.
1 Java Database Connection (JDBC) There are many industrial-strength DBMS's commercially available in the market. Oracle, DB2, and Sybase are just a few.
JDBC Java Database Connectivity. What is an RDBMS? Relational database management system. There are other kinds of DBMS. Access is a GUI on a JET RBDMS.
Overview of JDBC and Pro*C 1 Overview of JDBC,Pro*C and Oracle connectivity on Omega CSE 5330 – Database Systems.
© 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.
Intro to JDBC To effectively use Java Data Base Connectivity we must understand: 1.Relational Database Management Systems (RDBMS) 2.JDBC Drivers 3.SQL.
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.
A CCESSING D ATABASES WITH JDBC CH 24 C S 442: A DVANCED J AVA P ROGRAMMING.
CIS 270—Application Development II Chapter 25—Accessing Databases with JDBC.
RDB/1 An introduction to RDBMS Objectives –To learn about the history and future direction of the SQL standard –To get an overall appreciation of a modern.
DataBases and SQL INFSY 547 Spring Course Wrap Up April 12: Complete Work on Servlets Review of Team Projects Close of Portfolio Work April 19:
ABC Insurance Co. Paul Barry Steve Randolph Jing Zhou CSC8490 Database Systems & File Management Dr. Goelman Villanova University August 2, 2004.
CSC 411/511: DBMS Design Dr. Nan WangCSC411_L12_JDBC_MySQL 1 MySQL and JDBC.
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,
Overview of JDBC and Pro*C 1 CSE 5330 – Database Systems.
 2004 Prentice Hall, Inc. All rights reserved. 1 Segment – 6 Web Server & database.
1 Copyright © 2004, Oracle. All rights reserved. Introduction.
JDBC. JDBC stands for Java Data Base Connectivity. JDBC is different from ODBC in that – JDBC is written in Java (hence is platform independent, object.
JDBC. Preliminaries Database Database Collection of data Collection of data DBMS DBMS Database management system Database management system Stores and.
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.
COMP201 Java Programming Topic 15: Database Connectivity JDBC Reading: Chapter 4, Volume 2.
WEB/DB1 DATABASE PROGRAMMING 3JDBC by the ASU Scholars.
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.
Copyright © 2002 ProsoftTraining. All rights reserved. Building Database Client Applications Using JDBC 2.0.
JDBC. Java.sql.package The java.sql package contains various interfaces and classes used by the JDBC API. This collection of interfaces and classes enable.
12/6/2015B.Ramamurthy1 Java Database Connectivity B.Ramamurthy.
Java and Databases. JDBC Architecture Java Application JDBC API Data Base Drivers AccessSQL Server DB2InformixMySQLSybase.
COMP 321 Week 4. Overview Normalization Entity-Relationship Diagrams SQL JDBC/JDBC Drivers hsqldb Lab 4-1 Introduction.
UNIT III - JDBC JDBC Overview – JDBC implementation – Connection class – Statements - Catching Database Results, handling database Queries. Networking–
DATABASE CONNECTIVITY TO MYSQL. Introduction =>A real life application needs to manipulate data stored in a Database. =>A database is a collection of.
Database Access Using JDBC BCIS 3680 Enterprise Programming.
JDBC CS 260 Database Systems. Overview  Introduction  JDBC driver types  Eclipse project setup  Programming with JDBC  Prepared statements  SQL.
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.
Access Databases from Java Programs via JDBC Tessema M. Mengistu Department of Computer Science Southern Illinois University Carbondale
Learningcomputer.com SQL Server 2008 –Views, Functions and Stored Procedures.
Basics of JDBC Session 14.
Introduction to JDBC Instructor: Mohamed Eltabakh 1.
In the Name Of Almighty Allah. Java Application Connection To Mysql Created by Hasibullah (Sahibzada) Kabul Computer Science Faculty Afghanistan.
Intro to JDBC Joseph Sant Applied Computing and Engineering Sciences Sheridan ITAL.
Java and database. 3 Relational Databases A relational Database consists of a set of simple rectangular tables or relations The column headings are.
Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe.
JDBC. Database is used to store data permanently. These days almost all Applications needs database to store its data persistently. Below are the most.
DEPTT. OF COMP. SC & APPLICATIONS
JDBC Database Management Database connectivity
Web Technologies IT230 Dr Mohamed Habib.
JDBC.
Introduction to Server-Side Web Development using JSP and Databases
Interacting with Database
MSIS 655 Advanced Business Applications Programming
Java Database Connectivity
Java API for Database Connectivity
Presentation transcript:

DataBases and SQL INFSY 547 Spring 2007

Course Wrap Up April 12: Complete Work on Servlets Review of Team Projects Close of Portfolio Work April 19: Review Form ideas, Team Meetings and presentation guidelines April 26: Project Due Date Develop presentations May 3: Final Presentation and Party

Structured Query Language (SQL)  Used widely to interact with a variety of relational data bases  Oracle database management system

Relational Databases Relational databases stores data in tables Rows : represents a record Columns : represents individual fields of data Primary key: a column or group of columns in a table with a unique value Select stmts: specify which data to look at in a table Queries: define what will be selected from a table or group of tables

Sample Relational Data Base StudentTable studentId*studentFirstNamestudentLastName GradeTable studentcoursegrade  One:Many  * indicates primary key  minimally one table

Relational Databases –Foreign key:a column that is a primary key in another table –Referential Integrity: every foreign key must appear as another table’s primary key SELECT title, editionNumber, copyright FROM Titles WHERE copyright > 2000; sql statement

Creating a Database with SQL in Oracle Click on SQLPlus Note: 1) first time password is userid and new one will be required. 2) if already on the system, password is as before

Now You are Ready to Enter Commands from the Command Line!

Creating a Database with SQL in Oracle Create a table (create one of your choice) CREATE TABLE EmployeeTable ( emp_id char (5), emp-lName char (20), emp_fName char (15), emp_dept char (5), PRIMARY KEY (emp_id));

Relational Databases Other SQL Statements: INSERT INTO EmployeeTable (empId, fName, lName, dept) VALUES ( ‘101,‘Sue’, ‘Smith’,’MRKT’); UPDATE EmployeeTable SET lName = ‘Jones’ WHERE lName = ‘Smith’ and fName = ‘Sue’;

Other SQL Statements: DELETE FROM EmployeeTable WHERE lastName = ‘Jones’ and firstName = ‘Sue’; List your table name(s): SELECT table_name from user_tables;

SQL Statements StatementPurpose SELECTSelects rows from a table INSERTInserts rows into a table DELETEDeletes rows from a table UPDATEUpdates rows in a table COMMITCommits a transaction ROLLBACKRolls back a transaction GRANTGrants security rights REVOKERevokes security rights

Work with your table!

Granting Privileges GRANT SELECT ON EMPLOYEE TO JTS1; GRANT UPDATE ON EMPLOYEE TO JTS1; GRANT DELETE ON EMPLOYEE TO JTS1; GRANT ALTER ON EMPLOYEE TO JTS1;

Java Application JDBC Driver Manager JDBC-ODBC Bridge Vendor JDBC Driver Vendor OBDC Driver DataBASE Servlets and Java Server Pages, M. Hall and L. Brown, Sun Vendor Drivers result in best performance

For vendor JDBC Must be compiled with a special library file –classes12.jar (comes with Oracle products or download from my personal site) –Place in the common/lib in the TomCat directory

Java DataBase Connectivity (JDBC)  Connect to Oracle  Build queries in servlets  Display database information

Database Server Interpret SQL statements Optimize queries Prevent errors connected to concurrent user access Detect and act upon deadlock Administer security Administer backup and recovery

Relational Middleware SQL API (Application Programming Interface) –Facility to embed SQL code within procedural languages Database Driver –Software which format SQL statements and send them to the server Protocol Stack –Used for communicating between client and server

Relational Middleware

JDBC Steps to be programmed to access a relational database using Java 1.Load a driver compatible with the database being used. 2.Establish a connection to the database 3.Associate an SQL statement with this connection 4.Execute the SQL statement 5.SQL statement will produce a table stored in a ResultSet object.

JDBC 6.When processing is complete, database is closed 7.Connection to the database is closed; be sure to do so in the program

JDBC The JBDC API is contained in the java.sql package which contains: –Eight interfaces –Six classes –Three exceptions

JDBC DriverManager Class –Class manages JDBC drivers and provides uniform interface for establishing connections to databases

JDBC  Load the driver by calling : Class.forName(driverClassName); Class.forName( "oracle.jdbc.driver.OracleDriver" ); If the driver can’t be loaded, a ClassNotFoundException is thrown.

JDBC If the connection can’t be made, an SQLException is thrown.

JDBC A Connection (or session) interface must be implemented DriverManager.getConnection(String name, String user, String password); = 4.66:1521:CLDB",“ ",”<password");