Java Database Conectivity Julio M. Faerman. Arquitetura Java Database Connectivity # 2 AplicaçãoJDBC API Driver Manager JDBC Driver SGBDR AplicaçãoJDBC.

Slides:



Advertisements
Similar presentations
Slide 1 Insert your own content. Slide 2 Insert your own content.
Advertisements

Business Transaction Management Software for Application Coordination 1 Business Processes and Coordination.
5 Copyright © 2005, Oracle. All rights reserved. Accessing the Database with Servlets.
16 Copyright © 2005, Oracle. All rights reserved. Using JDBC to Access the Database.
0 - 0.
DIVIDING INTEGERS 1. IF THE SIGNS ARE THE SAME THE ANSWER IS POSITIVE 2. IF THE SIGNS ARE DIFFERENT THE ANSWER IS NEGATIVE.
ADDING INTEGERS 1. POS. + POS. = POS. 2. NEG. + NEG. = NEG. 3. POS. + NEG. OR NEG. + POS. SUBTRACT TAKE SIGN OF BIGGER ABSOLUTE VALUE.
SUBTRACTING INTEGERS 1. CHANGE THE SUBTRACTION SIGN TO ADDITION
MULT. INTEGERS 1. IF THE SIGNS ARE THE SAME THE ANSWER IS POSITIVE 2. IF THE SIGNS ARE DIFFERENT THE ANSWER IS NEGATIVE.
Addition Facts
©2010 PROS Holdings, Inc. All rights reserved. My JDBC Performance Sucks and What I Did About It!
© S Haughton more than 3?
IV1351 ht2010 nikos dimitrakas KTH/ICT/SCS 1 Embedded SQL i Java nikos dimitrakas rum 6626 Connolly/Begg(3rd edition) Kapitel 21.
Persistence Jim Briggs 1. 2 Database connectivity: JDBC Java Database Connectivity An API for connecting Java programs (applications, applets and servlets)
Past Tense Probe. Past Tense Probe Past Tense Probe – Practice 1.
Addition 1’s to 20.
25 seconds left…...
Test B, 100 Subtraction Facts
Week 1.
Java II--Copyright © Tom Hunter. Chapter 18 JDBC.
WaveMaker Visual AJAX Studio 4.0 Training
Exercises of the Tutorial on Advanced Web Programming Authors: Miroslava Mitrovic Dragan Milicev Nino.
Database By: Greg 4/10/2017 Java 9 - GUI.
Copyright  Oracle Corporation, All rights reserved. 2 Java and Databases: An Overview.
Helia / Martti Laiho, JDBC Java Database Connection.
MC365 JDBC and Server-Side Programming: Updating a database via JDBC & Connection Pooling.
JDBC - Java Database Connectivity The objectives of this chapter are: To describe the architecture of JDBC To outline the classes in the java.sql package.
Fundamentals, Design, and Implementation, 9/e Chapter 14 JDBC, Java Server Pages, and MySQL.
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.
JDBC Java API for Database Connectivity. Layout of this recitation Introduction to JDBC API JDBC Architecture Understanding the design of JDBC API –Classes.
JDBC / ODBC JDBC is the java API that facilitate interaction of a java application with the DBMS. FIRST APPROACH:
Database applications with JDBC Jiafan Zhou. DBMS Database management systems (DBMS) is an organised collection of data. Usually database stores data.
JDBC. What is JDBC JDBC is an acronym for –Java Data Base Connectivity. It allows java/jsp program to connect to any database.
Java Database Connectivity (JDBC) Introduction to JDBC JDBC is a simple API for connecting from Java applications to multiple databases. Lets you smoothly.
Java Utility Classes CS 21b. Some Java Utility Classes Vector Hashtable StringTokenizer * import java.util.*;
Using Java with PSQL and Oracle Thanks to Drs. Raj and Liu for sharing some of these slides TRUDY: ALSO NEED SAMPLE PROGRAM.
JDBC. JDBC Drivers JDBC is an alternative to ODBC and ADO that provides database access to programs written in Java.
JDBC (Java Database Connectivity) SNU OOPSLA Lab. October 2005.
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui COMP 302 Database Systems Java Data Base Connectivity Lecturer Dr Pavle Mogin.
Connecting to Oracle using Java November 4, 2009 David Goldschmidt, Ph.D. David Goldschmidt, Ph.D.
JDBC Java and Databases, including Postgress. JDBC l Developed by Industry leaders l Three main goals: –JDBC should be an SQL-level API –JDBC should capitalize.
Introduction to JDBC Michelle Lee, Ye Wu & Jeff Offutt SWE 432 Design and Implementation of Software for the Web.
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.
Sadegh Aliakbary. Copyright ©2014 JAVACUP.IRJAVACUP.IR All rights reserved. Redistribution of JAVACUP contents is not prohibited if JAVACUP.
JDBC Enterprise Systems Programming. JDBC  Java Database Connectivity  Database Access Interface provides access to a relational database (by allowing.
WEB/DB1 DATABASE PROGRAMMING 3JDBC by the ASU Scholars.
JDBC Session 2 Tonight’s topics: 1.Prepared Statements 2.Transaction Processing 3.Callable Statements & Stored Procedures 4.Scrollable & Updatable Result.
JDBC – Java Database Concentricity
Copyright  Oracle Corporation, All rights reserved. 6 Accessing a Database Using the JDBC API.
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.
Java Database Connectivity. Java and the database Database is used to store data. It is also known as persistent storage as the data is stored and can.
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.
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.
JDBC By 朱志興. Four driver types of JDBC (1) JDBC-ODBC bridge plus ODBC driver: Java Database Client JDBC- ODBC bridge ODBC driver Database Server A B C.
JDBC and SQLJ CIS 612 Spring JDBC JDBC is an API that enables database access from Java programs JDBC for DB access provides ◦ Portability across.
Basics of JDBC.
Introduction to JDBC Instructor: Mohamed Eltabakh 1.
Intro to JDBC Joseph Sant Applied Computing and Engineering Sciences Sheridan ITAL.
JDBC Statements The JDBC Statement, CallableStatement, and PreparedStatement interfaces define the methods and properties that enables to send SQL or PL/SQL.
JDBC.
JDBC Java Data Base Connectivity נערך ע"י: אורי רוטנברג הנחיה: ד"ר תמר בניה קורס: סדנא ב-Java.
JSP and DB.
Database: JDBC Overview
Database JDBC Overview CS Programming Languages for Web Applications
Interacting with Database
Java API for Database Connectivity
JDBC Example.
Data Access Layer (Con’t) (Overview)
Presentation transcript:

Java Database Conectivity Julio M. Faerman

Arquitetura Java Database Connectivity # 2 AplicaçãoJDBC API Driver Manager JDBC Driver SGBDR AplicaçãoJDBC API Driver Manager Ponte JDBC-ODBC Driver ODBCSGBDR

Classes e dependências Java Database Connectivity # 3

JDBC API 1.Class.forName("org.apache.derby.jdbc.ClientDriver"); 2.Connection conn = DriverManager.getConnection("jdbc:derby://localhost:1527 /maindb","root","masterkey"); 3.Statement stmt = conn.createStatement(); 4.stmt.executeUpdate("INSERT INTO FILME …."); 5.ResultSet rs = stmt.executeQuery("SELECT * FROM FILME"); 6.while(rs.next()){ System.out.println(rs.getString("TITULOORIGINAL"));} 7.conn.close(); Java Database Connectivity # 4

Statements Satement –execute –executeQuery –executeUpdate –executeBatch PreparedStatement –setString, setInt, setDouble, setDate,… Java Database Connectivity # 5

Transações TX 1 SELECT INSERT UPDAT E DELETE TX 2 UPDAT E DELETE INSERT TX 3 SELECT DELETE INSERT UPDAT E Java Database Connectivity # 6

Transações A tômicas C onsistentes I soladas I soladas D uráveis Java Database Connectivity # 7

API Connection –setAutoCommit(boolean autoCommit) –commit() –Rollback() –setTransactionIsolation(int level) Java Database Connectivity # 8

Anomalias em Transações Dirty Reads (Leitura Suja) –A(UPDATE) B(SELECT) Non-repeatable reads (Leitura não repetível) –A(SELECT) B(UPDATE) A(SELECT) Phantom reads (Leitura fantasma) –A(SELECT) B(INSERT) Java Database Connectivity # 9

Anomalias por nível de isolamento Nível de isolamentoDirtyNon RepeatablePhantom NONESIM READ_UNCOMMITTEDSIM READ_COMMITTEDNÃOSIM REPEATABLE_READNÃO DEPENDE SERIALIZABLENÃO Java Database Connectivity # 10 MCNH: Específico por banco Considere o locking MCNH: Específico por banco Considere o locking

Transações Distribuidas Java Database Connectivity # 11 Server 1 Server 2 Server 3 DB 1 DB 2 MQ TX Manager (2PC/XA,3P C) TX Manager (2PC/XA,3P C)

Connection Pooling Java Database Connectivity # 12 DB DataSourc e

JDBC: Outras Funcionalidades Stored Procedures Metadata Savepoints RowId Java Database Connectivity # 13

Exercício: CRUD via JDBC Java Database Connectivity # 14

Exercício: Multiplos DBs ou armazenamentos SQL Dialects –Geração de chaves –TOP / LIMIT –Oracle Connect By –… SGBD(R,PR,OO,XML…) E Arquivos Java Database Connectivity # 15 Cuidados com operadores condicionais Herança e do polimorfismo podem ajudar Separe responsabilidades

Data Access Object Java Database Connectivity # 16

DAO + Abstract Factory Java Database Connectivity # 17

Abstract Factory Desenvolvimento web com Java # 18

Java Database Connectivity # 19 Dúvidas ?