JDBC II IS 313 1.23.2003 1.

Slides:



Advertisements
Similar presentations
Structured Query Language - SQL Carol Wolf Computer Science.
Advertisements

JDBC CS-328. JDBC Java API for accessing RDBMS Allows use of SQL for RDBMS programming Can be used for: –embedded SQL –execution of stored queries.
Structured query language This is a presentation by JOSEPH ESTRada on the beauty of Structured Query Language.
Murali Mani SQL DDL and Oracle utilities. Murali Mani Datatypes in SQL INT (or) INTEGER FLOAT (or) REAL DECIMAL (n, m) CHAR (n) VARCHAR (n) DATE, TIME.
SQLite 1 CS440. What is SQLite?  Open Source Database embedded in Android  SQL syntax  Requires small memory at runtime (250 Kbytes)  Lightweight.
Phonegap Bridge – File System CIS 136 Building Mobile Apps 1.
DATABASES AND SQL. Introduction Relation: Relation means table(data is arranged in rows and columns) Domain : A domain is a pool of values appearing in.
Web Application Development Muhammad Ali Versonic Pte Asher Imtiaz Forman Christian College.
Training - Day 3 OJB. What is OR Mapping? OR Mapping is the mapping of relational database tables to objects (Java Objects in our case) Many OR Mapping.
PHP1-1 PHP & SQL Xingquan (Hill) Zhu
 SQL stands for Structured Query Language.  SQL lets you access and manipulate databases.  SQL is an ANSI (American National Standards Institute) standard.
HAP 709 – Healthcare Databases SQL Data Manipulation Language (DML) Updated Fall, 2009.
CS 3630 Database Design and Implementation. Your Oracle Account UserName is the same as your UWP username Followed Not case sensitive Initial.
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Chapter 38 Advanced Java Database.
CHAPTER:14 Simple Queries in SQL Prepared By Prepared By : VINAY ALEXANDER ( विनय अलेक्सजेंड़र ) PGT(CS),KV JHAGRAKHAND.
JDBC Tutorial MIE456 - Information Systems Infrastructure II Vinod Muthusamy November 4, 2004.
Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.
CSC 2720 Building Web Applications Database and SQL.
1 Structured Query Language (SQL). 2 Contents SQL – I SQL – II SQL – III SQL – IV.
1 JDBC Aum Amriteshwaryai Namah. 2 2 JDBC – Java DataBase Connectivity.
Liang, Introduction to Java Programming, Fifth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 33 Advanced Java.
JDBC Enterprise Systems Programming. JDBC  Java Database Connectivity  Database Access Interface provides access to a relational database (by allowing.
Chapter 8 Databases.
Databases MIS 21. Some database terminology  Database: integrated collection of data  Database Management System (DBMS): environment that provides mechanisms.
5. Simple SQL using Oracle1 Simple SQL using Oracle 5. Working with Tables: Data management and Retrieval 6. Working with Tables: Functions and Grouping.
Advanced Database CS-426 Week 1 - Introduction. Database Management System DBMS contains information about a particular enterprise Collection of interrelated.
DT228/3 Web Development Databases. Querying a database: Partial info Search engines, on-line catalogues often need to allow user to search a database.
SQL John Nowobilski. What is SQL? Structured Query Language Manages Data in Database Management Systems based on the Relational Model Developed in 1970s.
SQL Jan 20,2014. DBMS Stores data as records, tables etc. Accepts data and stores that data for later use Uses query languages for searching, sorting,
JDBC CS 124. JDBC Java Database Connectivity Database Access Interface provides access to a relational database (by allowing SQL statements to be sent.
Li Tak Sing COMPS311F. Database programming JDBC (Java Database Connectivity) Java version of ODBC (Open Database Connectivity) ODBC provides a standard.
CMPT 258 Database Systems The Relationship Model (Chapter 3)
NMED 3850 A Advanced Online Design January 14, 2010 V. Mahadevan.
SQLite DB Storing Data in Android RAVI GAURAV PANDEY 1.
Access Databases from Java Programs via JDBC Tessema M. Mengistu Department of Computer Science Southern Illinois University Carbondale
WEEK# 12 Haifa Abulaiha November 02,
Database: SQL, MySQL, LINQ and Java DB © by Pearson Education, Inc. All Rights Reserved.
Oracle & SQL. Oracle Data Types Character Data Types: Char(2) Varchar (20) Clob: large character string as long as 4GB Bolb and bfile: large amount of.
SQL. What is a database? G a collection of data G Usually consists of entities and relations G An entity is an individual “object” that exists and is.
JDBC I IS Why do we have databases?
JSP/Database Connectivity Instructor: Dr. M. Anwar Hossain.
Understand Data Definition Language (DDL) Database Administration Fundamentals LESSON 1.4.
JDBC Statements The JDBC Statement, CallableStatement, and PreparedStatement interfaces define the methods and properties that enables to send SQL or PL/SQL.
Big Data Yuan Xue CS 292 Special topics on.
JDBC III IS Outline  Scrollable ResultSets  Updatable ResultSets  Prepared statements  Stored procedures.
Standards and Conventions
CS242 SQL. What is SQL? SQL:  stands for Structured Query Language  allows you to access a database  is an ANSI standard computer language  can execute.
Creating Database Objects
Chapter 38 Advanced Java Database Programming
CS 3630 Database Design and Implementation
JDBC III IS
CIS 136 Building Mobile Apps
Chapter 41 Advanced Java Database Programming
Data Definition and Data Types
JDBC.
Design and Implementation of Software for the Web
Client Access, Queries, Stored Procedures, JDBC
Objectives In this lesson, you will learn about:
Relational Databases The Relational Model.
Relational Databases The Relational Model.
SQL data definition using Oracle
JDBC – Java Database Connectivity
CIS 136 Building Mobile Apps
Introduction to LINQ Chapter 11.
Introduction To Structured Query Language (SQL)
Introduction To Structured Query Language (SQL)
Data.
Structured Query Language Path from Unorganized to Organized….
Creating Database Objects
SQL (Structured Query Language)
Presentation transcript:

JDBC II IS 313 1.23.2003 1

Types Java types ≠ SQL types SQL types historical need for backwards compatibility

Numeric SQL types Integers Real numbers tiny int small int integer big int Real numbers real float decimal numeric

More SQL types Boolean String Binary Time bit char varchar long var char Binary binary var binary long var binary Time Date Timestamp

New SQL (99) Types Binary Large Object Character Large Object Array BLOB Character Large Object CLOB Array can manipulate without copying

Types in JDBC Accessors to ResultSet With column name String name = rs.getString (“Name”); With column number int id = rs.getInt(1);

Data accessors

INSERT statement INSERT INTO {table} VALUES ( {value1, …, valuen} ); INSERT INTO Reservations VALUES ( 1212, #1/23/2003#, ‘Sosa’, ‘Sammy’, 2, 14, 2 ); 15

UPDATE statement UPDATE {table} SET {column} = {value} WHERE { criteria } UPDATE Reservations SET RoomType = 4 WHERE ID = 1234; 15

DELETE statement DELETE FROM {table} WHERE { criteria } DELETE FROM Reservations WHERE ID = 9998; 15

JDBC Update queries No ResultSet returned Example 1 Example 2 String sql = “INSERT INTO Reservations “ + “VALUES (100, #12/11/2003#, ‘L.L.’, ‘Bean’, 2, 2, 2);”; int rows = stmt.executeUpdate(sql); // always 1 Example 2 String sql = “DELETE FROM Reservations WHERE (Date = #1/21/2003#);”; int rows = stmt.executeUpdate(sql); // how many rows deleted?

Assembling queries Use String operators (+) to assemble queries String sql = “INSERT INTO Reservations “ + “VALUES (100, #12/11/2003#, “ + firstName + “, “ + lastName + “, 2, 2, 2);”; int rows = stmt.executeUpdate(sql);

Program Development how do I start?

Steps Identify classes Identify properties Identify responsibilities Identify connection / communication Then Top-down elaboration Bottom-up implementation

Identify classes What sorts of “things” present themselves problem description real-world activities

Example Write a program reads a student id # from the command line retrieves student information from a database prints out the student’s enrollment information

Database Students table Enrollments table Id First Name Last Name Enrollment Id Student Id Date Course Number

Identify properties What constitutes the “state” of something? what distinguishes it from other instances? what does it need to “know” in order to function?

Identify responsibilities What does the object do? Always expose properties Other operations?

Identify connection / communication What other objects need to be connected to this one? Examples object A collects other objects object A calls methods of object B object A creates object B object A contains object B

Class design Arrive at Each with a set of classes coherent properties distinct reponsibilities well-defined relationships

Implementation Strategies Top-down Bottom-up work from the problem to the steps of its solution Bottom-up implement the methods of each class

Top-down Write down how the problem can be solved Turn this into Java using the classes you have outlined Turn this into Java then make each line function

Bottom-up For each class write instance variable for properties implement methods