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

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

JDBC Architecture. JDBC API: This provides the application-to- JDBC Manager connection.

Java Database Connectivity (JDBC) 25.1 What is JDBC?

Database Programming Overview. COSC 304 Introduction to Database Systems. Database Programming. JDBC Interfaces. JDBC Overview

Logging and Recovery. 444 Section, April 23, 2009

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

Java Database Connectivity

Database Application Development

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

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

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

Databases 2012 Embedded SQL

Lab # 9. Java to Database Connection

Databases and JDBC. by Vlad Costel Ungureanu for Learn Stuff

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

Java Database Connectivity

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

Three-Tier Architecture

Calling SQL from a host language (Java and Python) Kathleen Durant CS 3200

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

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

SQL in a Server Environment

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

Outline. Lecture 10: Database Connectivity -JDBC. Java Persistence. Persistence via Database

DataBase Lab JAVA-DATABASE CONNECTION. Eng. Haneen El-masry

Working with Databases and Java

Database Application Development

Accessing databases in Java using JDBC

Enterprise Systems. Lecture 02: JDBC. Behzad BORDBAR

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

Application Programming for Relational Databases

SQL DML and DB Applications, JDBC

Student Number: Please fill out the identification section above as well as the one on the back page, and read the instructions below. Good Luck!

Types of Databases. Types of Databases. Types of Databases. Databases and Web. Databases and Web. Relational databases may also have indexes

UNIT-3 Java Database Client/Server

SQL and Java. Database Systems Lecture 20 Natasha Alechina

Programming in Java

JAVA AND DATABASES. Summer 2018

Enterprise Java Unit 1- Chapter 6 Prof. Sujata Rizal

Introduction to Databases

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

DATABASE DESIGN I - 1DL300

Java Database Connectivity

e-pg Pathshala Subject: Computer Science Paper: Web Technology Module: JDBC INTRODUCTION Module No: CS/WT/26 Quadrant 2 e-text

JDBC 3.0. Java Database Connectivity. 1 Java

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

INTRODUCTION TO JDBC - Revised spring

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

The Web Application Developer s. Red Hat Database. View. October 30, Webcast. Patrick Macdonald, Fernando Nasser. Red Hat Database Engineering

The Object-Oriented Paradigm. Employee Application Object. The Reality of DBMS. Employee Database Table. From Database to Application.

INTRODUCTION TO JDBC - Revised Spring

UNIT III - JDBC Two Marks

PARTIAL Final Exam Reference Packet

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

Servlet 5.1 JDBC 5.2 JDBC

Java and the Java DataBase Connectivity (JDBC) API. Todd Kaufman April 25, 2002

O ne of the most important features of JavaServer

JDBC, Transactions. Niklas Fors JDBC 1 / 38

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

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

Chapter 16: Databases

Visit for more.

Top 50 JDBC Interview Questions and Answers

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

Instructor: Jinze Liu. Fall 2008

Unit 3 - Java Data Base Connectivity

Chapter 10 Java and SQL. Wang Yang

Chapter 5: Advanced SQL" Chapter 5: Advanced SQL"

Chapter 9 SQL in a server environment

Database connectivity (II)

DB Programming. Database Systems

DB I. 1 Dr. Ahmed ElShafee, Java course

Chapter 13 Introduction to SQL Programming Techniques

JDBC Java Database Connectivity is a Java feature that lets you connect

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

CHAPTER 44. Java Stored Procedures

SNS COLLEGE OF ENGINEERING, Coimbatore

JDBC Programming: Intro

JDBC [Java DataBase Connectivity]

PERSİSTENCE OBJECT RELATİON MAPPİNG

Database Application Development Part 2 - Chapter

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

Java E-Commerce Martin Cooke,

Database in Applica.on Development. Debapriyo Majumdar DBMS Fall 2016 Indian Statistical Institute Kolkata

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

Database Applications. SQL/PSM Embedded SQL JDBC

The Design of JDBC The Structured Query Language Basic JDBC Programming Concepts Query Execution Scrollable and Updatable Result Sets

PESIT Bangalore South Campus

Pieter van den Hombergh. March 25, 2018

Chapter 1 An introduction to relational databases and SQL

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

Web Applications and Database Connectivity using JDBC (Part II)

Database Application Programs PL/SQL, Java and the Web

UNIT 3 XML DATABASES

Embedded SQL. Introduction

Embedded SQL. Davood Rafiei

Lecture 9&10 JDBC. Mechanism. Some Warnings. Notes. Style. Introductory Databases SSC Introduction to DataBases 1.

13 Creation and Manipulation of Tables and Databases

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

3) execute() Usage: when you cannot determine whether SQL is an update or query return true if row is returned, use getresultset() to get the

Transcription:

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 Models in ERwin Logical Model allows conceptual modeling» simple data types (integer, string, date, etc.)» subclass support Physical Model needed for database schema generation a dedicated model for a particular database» specific data types of target database» subclass needs expanding 4

Modeling Procedure in ERwin Logical Model Physical Model Database Schema ERwin supports round-trip engineering Physical Model Database Schema We will practice this part in this HW 5

Example: Modeling and Schema Generation Create an ER model Select File > New > Create Model 6

Example: Modeling and Schema Generation Create an ER model (cont d) Entities (tables) and relationships Initial design Type setting 7

Example: Modeling and Schema Generation Create an ER model (cont d) Entities (tables) and relationships double click Initial design Type setting 8

Example: Modeling and Schema Generation Schema Generation Schema generation tools forward engineering 9

Example: Modeling and Schema Generation Schema Generation Schema generation tools forward engineering 10

Example: Modeling and Schema Generation Schema Generation Schema generation tools forward engineering 11

Example: Modeling and Schema Generation Schema Generation Schema generation tools forward engineering turn off Click 12

Example: Modeling and Schema Generation Schema Generation (cont d) 13

Example: Modeling and Schema Generation Schema Generation (cont d) Connection string is the net service name you configured with Oracle Net Configuration Assistant program (more on this later) 14

JDBC JDBC (Java Database Connectivity)» Java interfaces to interact with various databases applications use JDBC API to query databases database vendors implement drivers for their databases JDBC SQL statement ResultSet JDBC API JDBC Driver DBMS Applications 15

Example import java.sql.*; class Test { public static void main(string[] args) { Connection con = null; Statement stmt = null; try { Class.forName("oracle.jdbc.driver.OracleDriver"); con = DriverManager.getConnection( "jdbc:oracle:thin:@dbdynasty.kaist.ac.kr:1521:orcl", username", "password"); stmt = con.createstatement(); } ResultSet rs = stmt.executequery("select * from product"); while (rs.next()) { String product = rs.getstring( name ); System.out.println(product); } } catch (Exception e) { e.printstacktrace(); } 16

JDBC API Loading a JDBC driver use Class.forName() Class.forName( oracle.jdbc.driver.oracledriver ); Connecting to DB use DriverManager.getConnection() to get a Connection instance Connection con = DriverManager.getConnection( "jdbc:oracle:thin:@dbdynasty.kaist.ac.kr:1521:orcl", "username", "password"); orcl is SID of the Oracle database ( 서비스이름 ) 17

JDBC API (cont d) Executing queries Statement interface Statement stmt = con.createstatement(); ResultSet rs = stmt.executequery("select name from product"); PreparedStatement interface PreparedStatement pstmt = con.preparestatement( insert into product values(?,?) ); pstmt.setstring(1, mp3 ); pstmt.setint(2, 150); pstmt.executeupdate(); SELECT: executequery() INSERT, UPDATE, DELETE: executeupdate() or execute() 18

JDBC API (cont d) Retrieving query results ResultSet interface» next(), a series of get[type]() methods, etc. ResultSet rs = stmt.executequery("select * from product"); while (rs.next()) { String product = rs.getstring( name ); System.out.println(product); } Index-based retrieval (starting from 1): getint(int), getstring(int), Attribute-based retrieval: getint(string), getstring(string), 19

Server Information Server (Linux machine) domain name: dbdynasty.kaist.ac.kr your account (for login to the server)» userid: s[student_number], password: student_number ex) s20061234/20061234 Oracle database connection info.» port: 1521» SID: orcl your account (for login to the Oracle database)» the same as above 20

Required Software Oracle Client» includes JDBC driver and other useful programs such as SQL*Plus Download» download 10g_win32_client.zip from the following site Installation http://www.oracle.com/technology/software/products/database/oracle10» Unzip the downloaded file and run setup.exe be careful not to include any Korean characters in the path of your installation directory» Configure the net service name with Oracle Net Configuration Assistant (the name is used as connection string in schema generation in ERwin) SID ( 서비스이름 ) : orcl You must install the Oracle Client to use ERwin s schema generation feature 21

References ERwin 30-day evaluation version» http://dbserver.kaist.ac.kr/~mhkim/cs560-07spring.dir/erwin414sp2-b4033.exe ERwin Tutorial» Run ERwin, choose Help menu, and then select Tutorial JDBC Oracle JDBC driver» http://dbserver.kaist.ac.kr/~mhkim/cs560-07spring.dir/ojdbc14.jar» or you can find one in the Oracle Client installation directory JDBC Tutorial» http://java.sun.com/docs/books/tutorial/jdbc/ Advanced Tutorial» http://java.sun.com/developer/books/jdbctutorial/index.html 22