Oracle Object-Relational Features. Пыхалов А.В. ЮГИНФО

Size: px
Start display at page:

Download "Oracle Object-Relational Features. Пыхалов А.В. ЮГИНФО"

Transcription

1 Oracle Object-Relational Features Пыхалов А.В. ЮГИНФО

2 Две грубейшие ошибки ORсистем Под классом объектов понимаем тип данных, имеющий поля и методы Две ошибки OR систем Класс объекта == Отношение Работа с ссылками В результате СУБД нужно реализовывать больше логики, чем необходимо Что делать, если не найден объект по ссылке Можно ли делать проекции полей объектов (если класс объекта == отношение) 2

3 Поддержка объектов в Oracle Класс объекта==тип данных Допустимо явное использование ссылок на объекты Основные операции по работе с типами CREATE TYPE CREATE TYPE BODY Операции с объектами в таблицах должны осуществляться через alias-ы 3

4 Пример определения класса объектов CREATE OR REPLACE TYPE Person AS OBJECT ( name VARCHAR2(30), address VARCHAR2(30), age NUMBER, MEMBER PROCEDURE print ( SELF IN OUT NOCOPY Person ) ) NOT FINAL; / CREATE OR REPLACE TYPE BODY person AS MEMBER PROCEDURE print ( SELF IN OUT NOCOPY Person ) IS BEGIN DBMS_OUTPUT.PUT_LINE(name ' ' address ' ' TO_CHAR(age)); / CREATE TABLE people ( i int primary key, p person); INSERT INTO people VALUES( 1, person('ivan','some St.',23)); INSERT INTO people VALUES( 2, person('petr','other St.',32)); 4

5 Работа с методами Необходимо объявить метод ALTER TYPE person ADD MEMBER FUNCTION tostring RETURN VARCHAR2 ; Необходимо определить все неунаследованные методы CREATE OR REPLACE TYPE BODY person AS MEMBER PROCEDURE print ( SELF IN OUT NOCOPY Person ) IS BEGIN DBMS_OUTPUT.PUT_LINE(name ' ' address ' ' TO_CHAR(age)); MEMBER FUNCTION tostring RETURN VARCHAR2 IS BEGIN RETURN (name ' ' address ' ' TO_CHAR(age)); / 5

6 Определение иерархии классов объектов ALTER TYPE Person NOT FINAL CASCADE; CREATE OR REPLACE TYPE Student UNDER Person ( course NUMBER, OVERRIDING MEMBER FUNCTION tostring RETURN VARCHAR2, OVERRIDING MEMBER PROCEDURE print ); / CREATE OR REPLACE TYPE BODY student AS OVERRIDING MEMBER PROCEDURE print IS BEGIN DBMS_OUTPUT.PUT_LINE(name ' ' address ' ' TO_CHAR(age) ' ' TO_CHAR(course)); OVERRIDING MEMBER FUNCTION tostring RETURN VARCHAR2 IS BEGIN RETURN (name ' ' address ' ' TO_CHAR(age) ' ' TO_CHAR(course)); / ALTER TABLE people MODIFY COLUMN p SUBSTITUTABLE AT ALL LEVELS; INSERT INTO people VALUES( 3, student('alexey','some Other St.',22,4)); 6

7 Вызов функции объекта Вызов функции SELECT p, p.p.tostring() FROM people p; Результат работы P(NAME, ADDRESS, AGE) P.P.TOSTRING() PERSON('Ivan', 'Some St.', 23) Ivan Some St. 23 PERSON('Petr', 'Other St.', 32) Petr Other St. 32 STUDENT('Alexey', 'Some Other St.', 22, 4) Alexey Some Other St

8 Обращение к процедуре объекта set serveroutput on --В SQLPlus DECLARE CURSOR c1 IS SELECT p FROM people; per people.p%type; BEGIN OPEN c1; LOOP FETCH c1 INTO per; EXIT WHEN c1%notfound; IF per IS NOT NULL THEN per.print(); END IF; END LOOP; CLOSE c1; / Ivan Some St. 23 Petr Other St. 32 Alexey Some Other St Alexey Some Other St. 22 Alexandr Elm St. 23 Alexandr Elm St Alexandr Elm St Oleg Address 25 Alexandr Elm St. 23 PL/SQL procedure successfully completed. 8

9 Вложенные таблицы CREATE TYPE PointType AS OBJECT ( x NUMBER, y NUMBER); / CREATE TYPE PolygonType AS TABLE OF PointType; / CREATE TABLE Polygons ( name VARCHAR2(20), points PolygonType) NESTED TABLE points STORE AS PointsTable; --при этом points хранится как отдельная таблица PointsTable INSERT INTO Polygons VALUES( 'square', PolygonType(PointType(0, 0), PointType(0, 1), PointType(1, 0), PointType(1,1))); INSERT INTO Polygons VALUES( 'triangle', PolygonType(PointType(0, 0), PointType(0, 3), PointType(5, 1))); SELECT points FROM Polygons; NAME POINTS(X, Y) square POLYGONTYPE(POINTTYPE(0, 0), POINTTYPE(0, 1), POINTTYPE(1, 0), POINTTYPE(1, 1)) triangle POLYGONTYPE(POINTTYPE(0, 0), POINTTYPE(0, 3), POINTTYPE(5, 1)) 9

10 Ссылки CREATE TABLE Points OF PointType; CREATE TABLE Lines ( end1 REF PointType, end2 REF PointType); --заполним Lines... --Lines все линии, идущие слева направо INSERT INTO Lines SELECT REF(pp), REF(qq) FROM Points pp, Points qq WHERE pp.x < qq.x; SELECT ll.end1.x, ll.end2.x FROM Lines ll; --если выбрать ll.end1 или ll.end2 получим ссылку («мусор») END1.X END2.X

11 Java API Два стиля работы с объектами С использованием STRUCT классов Более удобен для работы с БД произвольной структуры С использованием Java-классов, соответствующих классам объектов БД Предпочтителен при работе с БД известной структуры Классы могут генерироваться с помощью специальной утилиты JPublisher 11

12 Использование STRUCT классов import java.sql.*; PreparedStatement ps=conn.preparestatement( import oracle.jdbc.*; "insert into people(p) values(?)"); import oracle.sql.*; StructDescriptor structdesc = import java.util.*; StructDescriptor.createDescriptor("PERSON",conn); //... Object [] attributes= OracleConnection conn = connect(); {"Oleg", "Address",25; Statement stmt = conn.createstatement(); STRUCT struct = ResultSet rset = stmt.executequery("select * from people"); new STRUCT(structdesc,conn,attributes); ResultSetMetaData rsmetadata = rset.getmetadata(); ps.setobject(1, struct); int numberofcolumns = rsmetadata.getcolumncount(); ps.execute(); while (rset.next()){ for(int i=1;i<=numberofcolumns-1;i++){ rsmetadata.getcolumntype(i); String str=rset.getstring(i); if(rset.wasnull()) System.out.print ("Null \t"); // Print col else System.out.print (str+"\t"); // Print col oracle.sql.struct oraclestruct=(oracle.sql.struct)rset.getobject(2); if(oraclestruct==null) System.out.print("(null)"); else{ System.out.print("("); oracle.sql.datum[] attrs = oraclestruct.getoracleattributes(); for(int i=0;i<attrs.length;i++){ if(attrs[i]==null) System.out.print("null"); else { if(attrs[i].getclass()==oracle.sql.number.class) System.out.print(((NUMBER)attrs[i]).intValue()); else System.out.print(attrs[i]); if(i!=attrs.length-1) System.out.print(")"); System.out.println(); rset.close(); stmt.close(); //... System.out.print("\t"); Результаты 1 (Ivan Some St. 23) 2 (Petr Other St. 32) 3 (Alexey Some Other St. 22 4) 4 (Alexey Some Other St. 22 null) 5 (null)... 12

13 Использование набора специальных классов. Класс Person class Person implements ORAData, ORADataFactory { static final Person _personfactory = new Person(); public CHAR name; public CHAR address; public NUMBER age; CharacterSet cs; public static ORADataFactory getoradatafactory() { return _personfactory; //Набор конструкторов public Person () { cs=characterset.make(characterset.default_charset); public Person(CHAR name, CHAR address, NUMBER age) {... public Person(String name, String address, int age) throws SQLException { cs=characterset.make(characterset.default_charset); setname(name); setaddress(address); setage(age); //Интерфейс ORAData //Создание объекта Datum из класса public Datum todatum(connection c) throws SQLException { StructDescriptor sd = StructDescriptor.createDescriptor("PERSON", c); Object [] attributes = { name, address, age ; return new STRUCT(sd, c, attributes); //Интерфейс ORADataFactory //Создание класса из объекта Datum public ORAData create(datum d, int sqltype) throws SQLException { if (d == null) return null; Object [] attributes = ((STRUCT) d).getoracleattributes(); return new Person((CHAR) attributes[0], (CHAR) attributes[1], (NUMBER) attributes[2]); public String tostring() {... public void setaddress(string address) throws SQLException{ this.address = new CHAR(address,cs); public void setage(int age) throws SQLException{ this.age = new NUMBER(age); public void setname(string name) throws SQLException{ this.name = new CHAR(name,cs); 13

14 Использование набора специальных классов. Продолжение Создание класса Student аналогично Person Создание собственной реализации ORADataFactory для различения Student и Person class PersonFactory implements ORADataFactory { static final PersonFactory _factory = new PersonFactory (); public static ORADataFactory getoradatafactory() { return _factory; public ORAData create(datum d, int sqltype) throws SQLException { STRUCT s = (STRUCT) d; if(s==null) return null; if (s.getsqltypename ().equals ("ALP.PERSON")) return Person.getORADataFactory().create(d, sqltype); else if (s.getsqltypename ().equals ("ALP.STUDENT")) return Student.getORADataFactory ().create(d, sqltype); else return null; 14

15 Фрагмент программы, использующий описанные классы System.setProperty("user.language", "ru"); OracleConnection conn = connect(); try{ Student st=new Student("Alexandr","Elm St.",23,1); OraclePreparedStatement ps= (OraclePreparedStatement)conn.prepareStatement("insert into people (p) values(?)"); ps.setoracleobject(1, st.todatum(conn)); //ps.setobject(1, st); -- не работает //ps.setoradata(1, st); -- не работает ps.execute(); Statement stmt = conn.createstatement(); OracleResultSet rset = (OracleResultSet)stmt.executeQuery("select * from people"); ResultSetMetaData rsmetadata = rset.getmetadata(); int numberofcolumns = rsmetadata.getcolumncount(); while (rset.next()){ for(int i=1;i<=numberofcolumns-1;i++){ rsmetadata.getcolumntype(i); String str=rset.getstring(i); if(rset.wasnull()) System.out.print ("Null \t"); // Print col 1 else System.out.print (str+"\t"); // Print col 1 //Получаем объект Student или Person Person p=(person)rset.getoradata(2, PersonFactory.getORADataFactory()); System.out.print (p); System.out.println(); rset.close(); stmt.close(); 15

16 Литература Oracle Database Object-Relational Developer's Guide 11g Release 1 (11.1) Oracle Database JDBC Developer's Guide and Reference, 11g Release 1 (11.1), chapter 13 Working with Oracle Object Types Oracle Database JPublisher User's Guide 11g Release 1 (11.1) Object-Relational Features of Oracle 16

Oracle Database 10g Java Web

Oracle Database 10g Java Web Oracle Database 10g Java Web 2005 5 Oracle Database 10g Java Web... 3... 3... 4... 4... 4 JDBC... 5... 5... 5 JDBC... 6 JDBC... 8 JDBC... 9 JDBC... 10 Java... 11... 12... 12... 13 Oracle Database EJB RMI/IIOP...

More information

ОБЪЕКТНО- ОРИЕНТИРОВАННОЕ ПРОГРАММИРОВАНИЕ. Лекция 1 / г.

ОБЪЕКТНО- ОРИЕНТИРОВАННОЕ ПРОГРАММИРОВАНИЕ. Лекция 1 / г. ОБЪЕКТНО- ОРИЕНТИРОВАННОЕ ПРОГРАММИРОВАНИЕ Лекция 1 / 04 04.03.2019 г. VIRTUAL DESTRUCTOR class Shape{ int x, y; Shape(int x, int y); ~Shape(){ printf("dtor shape!\n"); class Circle: public Shape{ int

More information

CSC System Development with Java. Database Connection. Department of Statistics and Computer Science. Budditha Hettige

CSC System Development with Java. Database Connection. Department of Statistics and Computer Science. Budditha Hettige CSC 308 2.0 System Development with Java Database Connection Budditha Hettige Department of Statistics and Computer Science Budditha Hettige 1 From database to Java There are many brands of database: Microsoft

More information

CMPUT 391 Database Management Systems. JDBC in Review. - Lab 2 -

CMPUT 391 Database Management Systems. JDBC in Review. - Lab 2 - CMPUT 391 Database Management Systems JDBC in Review - - Department of Computing Science University of Alberta What Is JDBC? JDBC is a programming interface JDBC allows developers using java to gain access

More information

Database Programming. Week 9. *Some of the slides in this lecture are created by Prof. Ian Horrocks from University of Oxford

Database Programming. Week 9. *Some of the slides in this lecture are created by Prof. Ian Horrocks from University of Oxford Database Programming Week 9 *Some of the slides in this lecture are created by Prof. Ian Horrocks from University of Oxford SQL in Real Programs We have seen only how SQL is used at the generic query interface

More information

How to program applications. CS 2550 / Spring 2006 Principles of Database Systems. SQL is not enough. Roadmap

How to program applications. CS 2550 / Spring 2006 Principles of Database Systems. SQL is not enough. Roadmap How to program applications CS 2550 / Spring 2006 Principles of Database Systems 05 SQL Programming Using existing languages: Embed SQL into Host language ESQL, SQLJ Use a library of functions Design a

More information

Chapter 1 : Overview

Chapter 1 : Overview Chapter 1 : Overview Overview of SQL3 Object Features * User defined data tyes * Oracle8/SQL Methods, Abstract Data Types * References, Collections, Large Object 2 Course Material Course Notes Butterfly

More information

CSE 135. Three-Tier Architecture. Applications Utilizing Databases. Browser. App. Server. Database. Server

CSE 135. Three-Tier Architecture. Applications Utilizing Databases. Browser. App. Server. Database. Server CSE 135 Applications Utilizing Databases Three-Tier Architecture Located @ Any PC HTTP Requests Browser HTML Located @ Server 2 App Server JDBC Requests JSPs Tuples Located @ Server 1 Database Server 2

More information

Part I: Stored Procedures. Introduction to SQL Programming Techniques. CSC 375, Fall 2017

Part I: Stored Procedures. Introduction to SQL Programming Techniques. CSC 375, Fall 2017 Introduction to SQL Programming Techniques CSC 375, Fall 2017 The Six Phases of a Project: Enthusiasm Disillusionment Panic Search for the Guilty Punishment of the Innocent Praise for non-participants

More information

Java Database Connectivity (JDBC) 25.1 What is JDBC?

Java Database Connectivity (JDBC) 25.1 What is JDBC? PART 25 Java Database Connectivity (JDBC) 25.1 What is JDBC? JDBC stands for Java Database Connectivity, which is a standard Java API for database-independent connectivity between the Java programming

More information

Enterprise Java Unit 1- Chapter 6 Prof. Sujata Rizal

Enterprise Java Unit 1- Chapter 6 Prof. Sujata Rizal Introduction JDBC is a Java standard that provides the interface for connecting from Java to relational databases. The JDBC standard is defined by Sun Microsystems and implemented through the standard

More information

Birkbeck (University of London) Software and Programming 1 In-class Test Mar 2018

Birkbeck (University of London) Software and Programming 1 In-class Test Mar 2018 Birkbeck (University of London) Software and Programming 1 In-class Test 2.1 22 Mar 2018 Student Name Student Number Answer ALL Questions 1. What output is produced when the following Java program fragment

More information

Designing a Persistence Framework

Designing a Persistence Framework Designing a Persistence Framework Working directly with code that uses JDBC is low-level data access; As application developers, one is more interested in the business problem that requires this data access.

More information

TypeScript. Часть II. Старков Дима

TypeScript. Часть II. Старков Дима TypeScript Часть II Старков Дима 1 Сегодня Вывод типов Структурная типизация Более сложные типы Обобщенные типы Type Guards 2 TypeScript? Спасет от выстрелов себе в ногу ESNext прямо сейчас Средство против

More information

VanillaCore Walkthrough Part 1. Introduction to Database Systems DataLab CS, NTHU

VanillaCore Walkthrough Part 1. Introduction to Database Systems DataLab CS, NTHU VanillaCore Walkthrough Part 1 Introduction to Database Systems DataLab CS, NTHU 1 The Architecture VanillaDB JDBC/SP Interface (at Client Side) Remote.JDBC (Client/Server) Query Interface Remote.SP (Client/Server)

More information

Three-Tier Architecture

Three-Tier Architecture Three-Tier Architecture Located @ Any PC HTTP Requests Microsoft Internet Explorer HTML Located @ Your PC Apache Tomcat App Server Java Server Pages (JSPs) JDBC Requests Tuples Located @ DBLab MS SQL Server

More information

Chapter 4 Application Programs and Object-Relational Capabilities

Chapter 4 Application Programs and Object-Relational Capabilities Chapter 4 Application Programs and Object-Relational Capabilities Recent Development for Data Models 2016 Stefan Deßloch The "Big Picture" SQL99 Client DB Server Server-side Logic dynamic SQL JDBC 2.0

More information

CSC317/MCS9317. Database Performance Tuning. Class test

CSC317/MCS9317. Database Performance Tuning. Class test CSC317/MCS9317 Database Performance Tuning Class test 7 October 2015 Please read all instructions (including these) carefully. The test time is approximately 120 minutes. The test is close book and close

More information

SQL and Java. Database Systems Lecture 20 Natasha Alechina

SQL and Java. Database Systems Lecture 20 Natasha Alechina Database Systems Lecture 20 Natasha Alechina In this Lecture SQL in Java SQL from within other Languages SQL, Java, and JDBC For More Information Sun Java tutorial: http://java.sun.com/docs/books/tutorial/jdbc

More information

COP4540 TUTORIAL PROFESSOR: DR SHU-CHING CHEN TA: H S IN-YU HA

COP4540 TUTORIAL PROFESSOR: DR SHU-CHING CHEN TA: H S IN-YU HA COP4540 TUTORIAL PROFESSOR: DR SHU-CHING CHEN TA: H S IN-YU HA OUTLINE Postgresql installation Introduction of JDBC Stored Procedure POSTGRES INSTALLATION (1) Extract the source file Start the configuration

More information

Outline. CS 235: Introduction to Databases. DB Application Programming. Interface Solutions. Basic PSM Form. Persistent Stored Modules

Outline. CS 235: Introduction to Databases. DB Application Programming. Interface Solutions. Basic PSM Form. Persistent Stored Modules Outline CS 235: Introduction to Databases Svetlozar Nestorov Database application programming SQL limitations SQL Persistent, Stored Modules (PSM) Extension of SQL PL/SQL: Oracle s version of PSM Lecture

More information

Oracle8i. JPublisher User s Guide. Release 2 (8.1.6) December 1999 Part No. A

Oracle8i. JPublisher User s Guide. Release 2 (8.1.6) December 1999 Part No. A Oracle8i JPublisher User s Guide Release 2 (8.1.6) December 1999 Part No. A81357-01 JPublisher User s Guide, Release 2 (8.1.6) Part No. A81357-01 Copyright 1996, 1999, Oracle Corporation. All rights reserved.

More information

JDBC Installation Transactions Metadata

JDBC Installation Transactions Metadata Course Name: Advanced Java Lecture 14 Topics to be covered JDBC Installation Transactions Metadata Steps in JDBC Connectivity:Connectivity:Here are the JDBC Steps to be followed while writing JDBC

More information

EMBEDDED SQL. SE 3DB3 Fall 2016 MICHAEL LIUT DEPARTMENT OF COMPUTING AND SOFTWARE MCMASTER UNIVERSITY

EMBEDDED SQL. SE 3DB3 Fall 2016 MICHAEL LIUT DEPARTMENT OF COMPUTING AND SOFTWARE MCMASTER UNIVERSITY EMBEDDED SQL MICHAEL LIUT (LIUTM@MCMASTER.CA) DEPARTMENT OF COMPUTING AND SOFTWARE MCMASTER UNIVERSITY SE 3DB3 Fall 2016 (Slides adapted from Dr. Fei Chiang, Diane Horton, examples from J. Ullman, J. Widom)

More information

BUSINESS INTELLIGENCE LABORATORY. Data Access: Relational Data Bases. Business Informatics Degree

BUSINESS INTELLIGENCE LABORATORY. Data Access: Relational Data Bases. Business Informatics Degree BUSINESS INTELLIGENCE LABORATORY Data Access: Relational Data Bases Business Informatics Degree RDBMS data access 2 Protocols and API ODBC, OLE DB, ADO, ADO.NET, JDBC JDBC Programming Java classes java.sql

More information

CHAPTER 44. Java Stored Procedures

CHAPTER 44. Java Stored Procedures CHAPTER 44 Java Stored Procedures 752 Oracle Database 12c: The Complete Reference You can write stored procedures, triggers, object type methods, and functions that call Java classes. In this chapter,

More information

Topic 12: Database Programming using JDBC. Database & DBMS SQL JDBC

Topic 12: Database Programming using JDBC. Database & DBMS SQL JDBC Topic 12: Database Programming using JDBC Database & DBMS SQL JDBC Database A database is an integrated collection of logically related records or files consolidated into a common pool that provides data

More information

CSCI/CMPE Object-Oriented Programming in Java JDBC. Dongchul Kim. Department of Computer Science University of Texas Rio Grande Valley

CSCI/CMPE Object-Oriented Programming in Java JDBC. Dongchul Kim. Department of Computer Science University of Texas Rio Grande Valley CSCI/CMPE 3326 Object-Oriented Programming in Java JDBC Dongchul Kim Department of Computer Science University of Texas Rio Grande Valley Introduction to Database Management Systems Storing data in traditional

More information

Goals for Today. CSE1030 Introduction to Computer Science II. CSE1030 Lecture #9. Review is-a versus has-a. Lecture #9 Inheritance I

Goals for Today. CSE1030 Introduction to Computer Science II. CSE1030 Lecture #9. Review is-a versus has-a. Lecture #9 Inheritance I CSE1030 Introduction to Computer Science II Lecture #9 Inheritance I Goals for Today Today we start discussing Inheritance (continued next lecture too) This is an important fundamental feature of Object

More information

Unit 3 - Java Data Base Connectivity

Unit 3 - Java Data Base Connectivity Two-Tier Database Design The two-tier is based on Client-Server architecture. The direct communication takes place between client and server. There is no mediator between client and server. Because of

More information

CHAPTER 5. Extending PL/SQL with Java Libraries. ORACLE Series / Expert Oracle PL/SQL / Hardman & McLaughlin / / Chapter 5 Blind Folio 5:103

CHAPTER 5. Extending PL/SQL with Java Libraries. ORACLE Series / Expert Oracle PL/SQL / Hardman & McLaughlin / / Chapter 5 Blind Folio 5:103 Blind Folio 5:103 CHAPTER 5 Extending PL/SQL with Java Libraries Thursday, August 18, 2005 9:57:32 AM 104 Expert Oracle PL/SQL E xtending stored programs with Java is a very popular solution. PL/SQL is

More information

CSCI 355 LAB #2 Spring 2004

CSCI 355 LAB #2 Spring 2004 CSCI 355 LAB #2 Spring 2004 More Java Objectives: 1. To explore several Unix commands for displaying information about processes. 2. To explore some differences between Java and C++. 3. To write Java applications

More information

Kyle Brown Knowledge Systems Corporation by Kyle Brown and Knowledge Systems Corporation

Kyle Brown Knowledge Systems Corporation by Kyle Brown and Knowledge Systems Corporation Kyle Brown Knowledge Systems Corporation 1 What is the JDBC? What other persistence mechanisms are available? What facilities does it offer? How is it used? 2 JDBC is the Java DataBase Connectivity specification

More information

Database Application Development

Database Application Development Database Application Development Linda Wu (CMPT 354 2004-2) Topics SQL in application code Embedded SQL JDBC SQLJ Stored procedures Chapter 6 CMPT 354 2004-2 2 SQL in Application Code SQL commands can

More information

Embedded SQL. csc343, Introduction to Databases Renée J. Miller and Fatemeh Nargesian and Sina Meraji Winter 2018

Embedded SQL. csc343, Introduction to Databases Renée J. Miller and Fatemeh Nargesian and Sina Meraji Winter 2018 Embedded SQL csc343, Introduction to Databases Renée J. Miller and Fatemeh Nargesian and Sina Meraji Winter 2018 Problems with using interactive SQL Standard SQL is not Turing-complete. E.g., Two profs

More information

Introduction to JDBC. JDBC: Java Database Connectivity. Why Access a Database with Java? Compilation. Six Steps. Packages to Import

Introduction to JDBC. JDBC: Java Database Connectivity. Why Access a Database with Java? Compilation. Six Steps. Packages to Import Introduction to JDBC JDBC: Java Database Connectivity JDBC is used for accessing databases from Java applications Information is transferred from relations to objects and vice-versa databases optimized

More information

Oracle Exam 1z0-809 Java SE 8 Programmer II Version: 6.0 [ Total Questions: 128 ]

Oracle Exam 1z0-809 Java SE 8 Programmer II Version: 6.0 [ Total Questions: 128 ] s@lm@n Oracle Exam 1z0-809 Java SE 8 Programmer II Version: 6.0 [ Total Questions: 128 ] Oracle 1z0-809 : Practice Test Question No : 1 Given: public final class IceCream { public void prepare() { public

More information

Java Database Connectivity

Java Database Connectivity Java Database Connectivity ADVANCED FEATURES Dr. Syed Imtiyaz Hassan Assistant Professor, Deptt. of CSE, Jamia Hamdard (Deemed to be University), New Delhi, India. s.imtiyaz@jamiahamdard.ac.in Agenda Scrollable

More information

CMSC 132: Object-Oriented Programming II. Inheritance

CMSC 132: Object-Oriented Programming II. Inheritance CMSC 132: Object-Oriented Programming II Inheritance 1 Mustang vs Model T Ford Mustang Ford Model T 2 Interior: Mustang vs Model T 3 Frame: Mustang vs Model T Mustang Model T 4 Compaq: old and new Price:

More information

J2EE Access of Relational Data

J2EE Access of Relational Data J2EE Access of Relational Data Direct JDBC Direct SQL calls, uses rows and result sets directly Object view Accessed as objects or components, transparent that the data is stored in relational database

More information

JDBC Drivers Type. JDBC drivers implement the defined interfaces in the JDBC API for interacting with your database server.

JDBC Drivers Type. JDBC drivers implement the defined interfaces in the JDBC API for interacting with your database server. JDBC Drivers Type 1 What is JDBC Driver? JDBC drivers implement the defined interfaces in the JDBC API for interacting with your database server. For example, using JDBC drivers enable you to open database

More information

SQL: Programming. Announcements (September 25) Motivation. CPS 116 Introduction to Database Systems. Pros and cons of SQL.

SQL: Programming. Announcements (September 25) Motivation. CPS 116 Introduction to Database Systems. Pros and cons of SQL. SQL: Programming CPS 116 Introduction to Database Systems Announcements (September 25) 2 Homework #2 due this Thursday Submit to Yi not through Jun s office door Solution available this weekend No class

More information

Бэкап и восстановление БД

Бэкап и восстановление БД Бэкап и восстановление БД 1. Типы сбоев 1) Сбой питания сервера СУБД. 2) Пользовательская ошибка 3) Ошибка, приведшая к повреждению некоторых файлов СУБД 4) Полный крах системы 2. Восстановление после

More information

UNIT-3 Java Database Client/Server

UNIT-3 Java Database Client/Server UNIT-3 Java Database Client/Server TOPICS TO BE COVERED 3.1 Client-Server Design: Two-Tier Database Design, Three-Tier Database Design 3.2 The JDBC API: The API Components, Database Creation, table creation

More information

ORACLE: PL/SQL Programming

ORACLE: PL/SQL Programming %ROWTYPE Attribute... 4:23 %ROWTYPE... 2:6 %TYPE... 2:6 %TYPE Attribute... 4:22 A Actual Parameters... 9:7 Actual versus Formal Parameters... 9:7 Aliases... 8:10 Anonymous Blocks... 3:1 Assigning Collection

More information

PESIT Bangalore South Campus

PESIT Bangalore South Campus INTERNAL ASSESSMENT TEST II Date : 20-09-2016 Max Marks: 50 Subject & Code: JAVA & J2EE (10IS752) Section : A & B Name of faculty: Sreenath M V Time : 8.30-10.00 AM Note: Answer all five questions 1) a)

More information

JDBC Programming: Intro

JDBC Programming: Intro JDBC Programming: Intro Most interaction with DB is not via interactive interface Most people interact via 1. Application programs directly 2. Apps over the internet There are 3 general approaches to developing

More information

Question Bank PL/SQL Fundamentals-I

Question Bank PL/SQL Fundamentals-I Question Bank PL/SQL Fundamentals-I UNIT-I Fundamentals of PL SQL Introduction to SQL Developer, Introduction to PL/SQL, PL/SQL Overview, Benefits of PL/SQL, Subprograms, Overview of the Types of PL/SQL

More information

Recitation: Loop Jul 7, 2008

Recitation: Loop Jul 7, 2008 Nested Loop Recitation: Loop Jul 7, 2008 1. What is the output of the following program? Use pen and paper only. The output is: ****** ***** **** *** ** * 2. Test this program in your computer 3. Use "for

More information

Pieter van den Hombergh. March 25, 2018

Pieter van den Hombergh. March 25, 2018 ergh Fontys Hogeschool voor Techniek en Logistiek March 25, 2018 ergh/fhtenl March 25, 2018 1/25 JDBC JDBC is a Java database connectivity technology (Java Standard Edition platform) from Oracle Corporation.

More information

Accessing databases in Java using JDBC

Accessing databases in Java using JDBC Accessing databases in Java using JDBC Introduction JDBC is an API for Java that allows working with relational databases. JDBC offers the possibility to use SQL statements for DDL and DML statements.

More information

Database Applications. SQL/PSM Embedded SQL JDBC

Database Applications. SQL/PSM Embedded SQL JDBC Database Applications SQL/PSM Embedded SQL JDBC 1 Course Objectives Design Construction Applications Usage 2 Course Objectives Interfacing When the course is through, you should Know how to connect to

More information

Servlet 5.1 JDBC 5.2 JDBC

Servlet 5.1 JDBC 5.2 JDBC 5 Servlet Java 5.1 JDBC JDBC Java DataBase Connectivity Java API JDBC Java Oracle, PostgreSQL, MySQL Java JDBC Servlet OpenOffice.org ver. 2.0 HSQLDB HSQLDB 100% Java HSQLDB SQL 5.2 JDBC Java 1. JDBC 2.

More information

Chapter 16: Databases

Chapter 16: Databases Chapter 16: Databases Starting Out with Java: From Control Structures through Objects Fifth Edition by Tony Gaddis Chapter Topics Chapter 16 discusses the following main topics: Introduction to Database

More information

1 of 6 11/08/2011 10:14 AM 1. Introduction 1.1. Project/Component Working Name: SJSAS 9.1, Support for JDBC 4.0 in JDBC RA, RFEs 1.2. Name(s) and e-mail address of Document Author(s)/Supplier: Jagadish

More information

ORM/Hibernate. Hibernate - это один из самых популярных на сегодняшний день ORM-фреймворков.

ORM/Hibernate. Hibernate - это один из самых популярных на сегодняшний день ORM-фреймворков. Hibernate ORM/Hibernate ORM(Object/Relational Mapping) - это способ сохранения объектов в реляционную базу данных. Другими словами ORM освобождает нас от работы с SQL и позволяет сосредоточиться на ООП.

More information

Discuss setting up JDBC connectivity. Demonstrate a JDBC program Discuss and demonstrate methods associated with JDBC connectivity

Discuss setting up JDBC connectivity. Demonstrate a JDBC program Discuss and demonstrate methods associated with JDBC connectivity Objectives Discuss setting up JDBC connectivity. Demonstrate a JDBC program Discuss and demonstrate methods associated with JDBC connectivity Setting Up JDBC Before you can begin to utilize JDBC, you must

More information

More Database Programming. CS157A Chris Pollett Nov. 2, 2005.

More Database Programming. CS157A Chris Pollett Nov. 2, 2005. More Database Programming CS157A Chris Pollett Nov. 2, 2005. Outline JDBC SQLJ Introduction Last day we went over some JDBC and SQLJ code examples from prior classes. Today, we will discuss JDBC and SQLJ

More information

Course Content. Objectives of Lecture 24 Inheritance. Outline of Lecture 24. Inheritance Hierarchy. The Idea Behind Inheritance

Course Content. Objectives of Lecture 24 Inheritance. Outline of Lecture 24. Inheritance Hierarchy. The Idea Behind Inheritance Structural Programming and Data Structures Winter 2000 CMPUT 102: Dr. Osmar R. Zaïane Course Content Introduction Objects Methods Tracing Programs Object State Sharing resources Selection Repetition Vectors

More information

Downloaded S. from Kiran, PGT (CS) KV, Malleswaram STRUCTURES. Downloaded from

Downloaded S. from Kiran,  PGT (CS) KV, Malleswaram STRUCTURES. Downloaded from Downloaded S. from Kiran, www.studiestoday.com PGT (CS) KV, STRUCTURES WHAT IS A STRUCTURE? Structure is a collection of logically related data. It is also a collection of dissimilar datatype. Downloaded

More information

Course Content. Objectives of Lecture 24 Inheritance. Outline of Lecture 24. CMPUT 102: Inheritance Dr. Osmar R. Zaïane. University of Alberta 4

Course Content. Objectives of Lecture 24 Inheritance. Outline of Lecture 24. CMPUT 102: Inheritance Dr. Osmar R. Zaïane. University of Alberta 4 Structural Programming and Data Structures Winter 2000 CMPUT 102: Inheritance Dr. Osmar R. Zaïane Course Content Introduction Objects Methods Tracing Programs Object State Sharing resources Selection Repetition

More information

IBM DB2 9 Application Developer. Download Full Version :

IBM DB2 9 Application Developer. Download Full Version : IBM 000-733 DB2 9 Application Developer Download Full Version : http://killexams.com/pass4sure/exam-detail/000-733 QUESTION: 130 A solution is needed to process a large amount of inventory table data on

More information

This lecture. Databases - JDBC I. Application Programs. Database Access End Users

This lecture. Databases - JDBC I. Application Programs. Database Access End Users This lecture Databases - I The lecture starts discussion of how a Java-based application program connects to a database using. (GF Royle 2006-8, N Spadaccini 2008) Databases - I 1 / 24 (GF Royle 2006-8,

More information

ERwin and JDBC. Mar. 6, 2007 Myoung Ho Kim

ERwin and JDBC. Mar. 6, 2007 Myoung Ho Kim ERwin and JDBC Mar. 6, 2007 Myoung Ho Kim ERwin ERwin a popular commercial ER modeling tool» other tools: Dia (open source), Visio, ConceptDraw, etc. supports database schema generation 2 ERwin UI 3 Data

More information

Databases 2012 Embedded SQL

Databases 2012 Embedded SQL Databases 2012 Christian S. Jensen Computer Science, Aarhus University SQL is rarely written as ad-hoc queries using the generic SQL interface The typical scenario: client server database SQL is embedded

More information

InfiniteGraph Manual 1

InfiniteGraph Manual 1 InfiniteGraph Manual 1 Installation Steps: Run the InfiniteGraph.exe file. Click next. Specify the installation directory. Click next. Figure 1: Installation step 1 Figure 2: Installation step 2 2 Select

More information

Delivering Rich Media Java Applications on Oracle9i Release 2. An Oracle White Paper June 2002

Delivering Rich Media Java Applications on Oracle9i Release 2. An Oracle White Paper June 2002 Delivering Rich Media Java Applications on Oracle9i Release 2 An Oracle White Paper June 2002 Delivering Rich Media Java Applications on Oracle9i Executive Overview...3 Introduction...3 What is oracle9i

More information

Exploring EJB3 With JBoss Application Server Part 6.2

Exploring EJB3 With JBoss Application Server Part 6.2 By Swaminathan Bhaskar 01/24/2009 Exploring EJB3 With JBoss Application Server Part 6.2 In this part, we will continue to explore Entity Beans Using Java Persistence API (JPA). Thus far, we have seen examples

More information

Embedded SQL. csc343, Introduction to Databases Diane Horton with examples from Ullman and Widom Fall 2014

Embedded SQL. csc343, Introduction to Databases Diane Horton with examples from Ullman and Widom Fall 2014 Embedded SQL csc343, Introduction to Databases Diane Horton with examples from Ullman and Widom Fall 2014 Problems with using interactive SQL Standard SQL is not Turing-complete. E.g., Two profs are colleagues

More information

Contents I Introduction 1 Introduction to PL/SQL iii

Contents I Introduction 1 Introduction to PL/SQL iii Contents I Introduction Lesson Objectives I-2 Course Objectives I-3 Human Resources (HR) Schema for This Course I-4 Course Agenda I-5 Class Account Information I-6 Appendixes Used in This Course I-7 PL/SQL

More information

Database Application Development

Database Application Development CS 461: Database Systems Database Application Development supplementary material: Database Management Systems Sec. 6.2, 6.3 DBUtils.java, Student.java, Registrar.java, RegistrarServlet.java, PgRegistrar.sql

More information

Chapter 10 Java and SQL. Wang Yang

Chapter 10 Java and SQL. Wang Yang Chapter 10 Java and SQL Wang Yang wyang@njnet.edu.cn Outline Concern Data - File & IO vs. Database &SQL Database & SQL How Connect Java to SQL - Java Model for Database Java Database Connectivity (JDBC)

More information

JDBC 3.0. Java Database Connectivity. 1 Java

JDBC 3.0. Java Database Connectivity. 1 Java JDBC 3.0 Database Connectivity 1 Contents 1 JDBC API 2 JDBC Architecture 3 Steps to code 4 Code 5 How to configure the DSN for ODBC Driver for MS-Access 6 Driver Types 7 JDBC-ODBC Bridge 8 Disadvantages

More information

Обзор веб-сайта alltechnews.net

Обзор веб-сайта alltechnews.net Обзор веб-сайта alltechnews.net Сгенерирован 30 Декабря 2018 12:50 Набрано баллов: 59/100 Заголовок страницы Home - Technology news Длина : 22 Замечательно, Ваш заголовок страницы содержит от 10 до 70

More information

Vendor: IBM. Exam Code: Exam Name: DB2 9 Application Developer. Version: Demo

Vendor: IBM. Exam Code: Exam Name: DB2 9 Application Developer. Version: Demo Vendor: IBM Exam Code: 000-733 Exam Name: DB2 9 Application Developer Version: Demo QUESTION 1 Which of the following applies to nickname usage? A. Nicknames cannot be created for views. B. An MQT definition

More information

SQL: Programming Midterm in class next Thursday (October 5)

SQL: Programming Midterm in class next Thursday (October 5) Announcements (September 28) 2 Homework #1 graded Homework #2 due today Solution available this weekend SQL: Programming Midterm in class next Thursday (October 5) Open book, open notes Format similar

More information

Database Access with JDBC. Dr. Jens Bennedsen, Aarhus University, School of Engineering Aarhus, Denmark

Database Access with JDBC. Dr. Jens Bennedsen, Aarhus University, School of Engineering Aarhus, Denmark Database Access with JDBC Dr. Jens Bennedsen, Aarhus University, School of Engineering Aarhus, Denmark jbb@ase.au.dk Overview Overview of JDBC technology JDBC drivers Seven basic steps in using JDBC Retrieving

More information

数据库系统概论讲义, 第 8 章编程 SQL,2015,3

数据库系统概论讲义, 第 8 章编程 SQL,2015,3 数据库系统概论 An Introduction to Database Systems 第八章数据库编程 (ODBC, PL/SQL) 2016, 3, 29 Programmatic SQL Three types of programmatic SQL Embedded SQL statements ISO standard specifies embedded support for C, COBOL,

More information

You write standard JDBC API application and plug in the appropriate JDBC driver for the database the you want to use. Java applet, app or servlets

You write standard JDBC API application and plug in the appropriate JDBC driver for the database the you want to use. Java applet, app or servlets JDBC Stands for Java Database Connectivity, is an API specification that defines the following: 1. How to interact with database/data-source from Java applets, apps, servlets 2. How to use JDBC drivers

More information

Web Applications and Database Connectivity using JDBC (Part II)

Web Applications and Database Connectivity using JDBC (Part II) Web Applications and Database Connectivity using JDBC (Part II) Advanced Topics in Java Khalid Azim Mughal khalid@ii.uib.no http://www.ii.uib.no/~khalid/atij/ Version date: 2007-02-08 ATIJ Web Applications

More information

Database Applications (15-415)

Database Applications (15-415) Database Applications (15-415) SQL-Part III & Storing Data: Disks and Files- Part I Lecture 8, February 5, 2014 Mohammad Hammoud Today Last Session: Standard Query Language (SQL)- Part II Today s Session:

More information

STUDENT LESSON A12 Iterations

STUDENT LESSON A12 Iterations STUDENT LESSON A12 Iterations Java Curriculum for AP Computer Science, Student Lesson A12 1 STUDENT LESSON A12 Iterations INTRODUCTION: Solving problems on a computer very often requires a repetition of

More information

CSCI 355 Lab #2 Spring 2007

CSCI 355 Lab #2 Spring 2007 CSCI 355 Lab #2 Spring 2007 More Java Objectives: 1. To explore several Unix commands for displaying information about processes. 2. To explore some differences between Java and C++. 3. To write Java applications

More information

An Interactive Program System for Training Students in Operation with Digital and Analog Regulators

An Interactive Program System for Training Students in Operation with Digital and Analog Regulators БЪЛГАРСКА АКАДЕМИЯ НА НАУКИТЕ. BULGARIAN ACADEMY OF SCIENCES ПРОБЛЕМИ НА ТЕХНИЧЕСКАТА КИБЕРНЕТИКА И РОБОТИКАТА, 46 PROBLEMS OF ENGINEERING CYBERNETICS AND ROBOTICS, 46 София. 1997. Sofia An Interactive

More information

More sophisticated behaviour Lecture 09

More sophisticated behaviour Lecture 09 More sophisticated behaviour Lecture 09 Waterford Institute of Technology February 22, 2016 John Fitzgerald Waterford Institute of Technology, More sophisticated behaviour Lecture 09 1/42 Presentation

More information

Introduction to SQL & Database Application Development Using Java

Introduction to SQL & Database Application Development Using Java Introduction to SQL & Database Application Development Using Java By Alan Andrea The purpose of this paper is to give an introduction to relational database design and sql with a follow up on how these

More information

Java Database Connectivity

Java Database Connectivity Java Database Connectivity INTRODUCTION Dr. Syed Imtiyaz Hassan Assistant Professor, Deptt. of CSE, Jamia Hamdard (Deemed to be University), New Delhi, India. s.imtiyaz@jamiahamdard.ac.in Agenda Introduction

More information

Tiers (or layers) Separation of concerns

Tiers (or layers) Separation of concerns Tiers (or layers) Separation of concerns Hiding the type of storage from the client class Let s say we have a program that needs to fetch objects from a storage. Should the program have to be concerned

More information

Максим Грамин КРОК. В поисках идеального инструмента

Максим Грамин КРОК. В поисках идеального инструмента Максим Грамин КРОК В поисках идеального инструмента Disclaimer Личное мнение на личном опыте Немного о себе Немного о себе Немного о себе Немного о себе Немного о себе Одинаковые проблемы Версионность

More information

Programming in Oracle with PL/SQL. Procedural Language Extension to SQL

Programming in Oracle with PL/SQL. Procedural Language Extension to SQL Programming in Oracle with PL/SQL Procedural Language Extension to SQL PL/SQL Allows using general programming tools with SQL, for example: loops, conditions, functions, etc. This allows a lot more freedom

More information

Unit 2 JDBC Programming

Unit 2 JDBC Programming Q1. What is JDBC? Explain the types of JDBC drivers? Ans. What is JDBC? JDBC is an API, which is used in java programming for interacting with database. JDBC (Java DataBase Connection) is the standard

More information

SQL Environment: Module Types. System Aspects of SQL. SQL Environment: Introduction. SQL Environment: Introduction. SQL Environment: Privileges

SQL Environment: Module Types. System Aspects of SQL. SQL Environment: Introduction. SQL Environment: Introduction. SQL Environment: Privileges SQL Environment: Module Types System Aspects of SQL Generic SQL Interface: Module: each query or statement Embedded SQL: SQL statements within host-language program SQL statements pre-processed to function

More information

Lesson B Objectives IF/THEN. Chapter 4B: More Advanced PL/SQL Programming

Lesson B Objectives IF/THEN. Chapter 4B: More Advanced PL/SQL Programming Chapter 4B: More Advanced PL/SQL Programming Monday 2/23/2015 Abdou Illia MIS 4200 - Spring 2015 Lesson B Objectives After completing this lesson, you should be able to: Create PL/SQL decision control

More information

Lecture 2. Introduction to JDBC

Lecture 2. Introduction to JDBC Lecture 2 Introduction to JDBC Introducing JDBC According to Sun, JDBC is not an acronym, but is commonly misinterpreted to mean Java DataBase Connectivity JDBC: is an API that provides universal data

More information

Cyrus Shahabi Computer Science Department University of Southern California C. Shahabi

Cyrus Shahabi Computer Science Department University of Southern California C. Shahabi Application Programming for Relational Databases Cyrus Shahabi Computer Science Department University of Southern California shahabi@usc.edu 1 Overview JDBC Package Connecting to databases with JDBC Executing

More information

Application Programming for Relational Databases

Application Programming for Relational Databases Application Programming for Relational Databases Cyrus Shahabi Computer Science Department University of Southern California shahabi@usc.edu 1 Overview JDBC Package Connecting to databases with JDBC Executing

More information

Подключение ультразвукового датчика HC-SR04

Подключение ультразвукового датчика HC-SR04 Подключение ультразвукового датчика HC-SR04 Датчик HC-SR-04 состоит из передатчика, приемника и схемы управления. Для наиболее оптимального режима поиска препятствий датчик устанавливается на сервомотор

More information

System Aspects of SQL

System Aspects of SQL System Aspects of SQL SQL Environment User Access Control SQL in Programming Environment Embedded SQL SQL and Java Transactions (Programmers View) SQL Environment: Introduction SQL server Supports operations

More information

Abstract class & Interface

Abstract class & Interface Islamic University of Gaza Faculty of Engineering Computer Engineering Department Computer Programming Lab (ECOM 2124) Lab 3 Abstract class & Interface Eng. Mohammed Abdualal Abstract class 1. An abstract

More information

General Overview - rel. model. Carnegie Mellon Univ. Dept. of Computer Science Database Applications. Reminder: our Mini-U db

General Overview - rel. model. Carnegie Mellon Univ. Dept. of Computer Science Database Applications. Reminder: our Mini-U db Faloutsos 15-415 Carnegie Mellon Univ. Dept. of Computer Science 15-415 - Database Applications Lecture#8 (cont d): SQL, Part 2 General Overview - rel. model Formal query languages rel algebra and calculi

More information