Object-Oriented Software How does it differ from procedural? How is it similar to procedural? Why has it become so popular? Does it replace or supplement.

Slides:



Advertisements
Similar presentations
Connecting to Databases. relational databases tables and relations accessed using SQL database -specific functionality –transaction processing commit.
Advertisements

JDBC. Java Database Connectivity (JDBC) Use the java.sql package to query and update the database. JDBC is an API that allows java to communicate with.
Introduction to XML CS348 Information System Guest Lecture Hazem Elmeleegy.
Distributed Application Development B. Ramamurthy.
15-Jun-15 JDBC. JDBC is a Sun trademark It is often taken to stand for Java Database Connectivity Java is very standardized, but there are many versions.
Java Database Connectivity (JDBC) java.sql package to query and update the database. JDBC is an API that allows java to communicate with a database server.
Java Database Connectivity By: Abe Marji CS616. Agenda 1.Quick Review of Databases 2.What is SQL? 3.What is JDBC? 4.Advanced Functions of JDBC 5.Summary.
1 Foundations of Software Design Lecture 27: Java Database Programming Marti Hearst Fall 2002.
Three-Tier Architecture Oracle DB Server Apache Tomcat App Server Microsoft Internet Explorer HTML Tuples HTTP Requests JDBC Requests Java Server Pages.
UFCE4Y UFCE4Y-20-3 Components and Services Julia Dawson.
JAVA JDBC JAVA JDBC Java Database Programming Lamiaa Said.
Advance Computer Programming Java Database Connectivity (JDBC) – In order to connect a Java application to a database, you need to use a JDBC driver. –
Introduction To System Analysis and design
Getting connected.  Java application calls the JDBC library.  JDBC loads a driver which talks to the database.  We can change database engines without.
1 CSC 440 Database Management Systems JDBC This presentation uses slides and lecture notes available from
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.
CS178 Database Management “JDBC”. What is JDBC ? JDBC stands for “Java DataBase Connectivity” The standard interface for communication between a Java.
Beginning Databases with JDBC Mike Bradley Adapted from and notes by Kevin Parker, Ph.D.
Database Programming in Java Corresponds with Chapter 32, 33.
Database Environment Chapter 2 AIT632 Sungchul Hong.
MySQL, Java, and JDBC CSE 3330 Southern Methodist University.
JDBC Tutorial MIE456 - Information Systems Infrastructure II Vinod Muthusamy November 4, 2004.
JAVA Database Access. JDBC The Java Database Connectivity (JDBC) API is the industry standard for database- independent connectivity between the Java.
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.
1 Module Objective & Outline Module Objective: After completing this Module, you will be able to, appreciate java as a programming language, write java.
An Introduction to Java Chapter 11 Object-Oriented Application Development: Part I.
Servlets Database Access. Agenda:  Setup Java Environment  Install Database  Install Database Drivers  Create Table and add records  Accessing a.
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.
Stored procedures1 Stored procedures and functions Procedures and functions stored in the database.
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  The JDBC (Java Database Connectivity) API helps a Java program to access a database in a standard way  JDBC is a specification that tells the.
JDBC Java and Databases. RHS – SOC 2 JDBC JDBC – Java DataBase Connectivity An API (i.e. a set of classes and methods), for working with databases in.
JSP program that interacts with HTML form & Access Data Base.
Copyright  Oracle Corporation, All rights reserved. 6 Accessing a Database Using the JDBC API.
Chapter 25 Databases. Chapter Scope Database concepts Tables and queries SQL statements Managing data in a database Java Foundations, 3rd Edition, Lewis/DePasquale/Chase25.
Copyright  Oracle Corporation, All rights reserved. 7 Accessing a Database Using SQLJ.
JDBC - Connection The programming involved to establish a JDBC connection is fairly simple. Here are these simple four steps − Import JDBC Packages: Add.
JDBC Database Programming in Java Prepared by., Mrs.S.Amudha AP/SWE.
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.
Li Tak Sing COMPS311F. Database programming JDBC (Java Database Connectivity) Java version of ODBC (Open Database Connectivity) ODBC provides a standard.
Java and Databases. JDBC Architecture Java Application JDBC API Data Base Drivers AccessSQL Server DB2InformixMySQLSybase.
DATABASE CONNECTIVITY TO MYSQL. Introduction =>A real life application needs to manipulate data stored in a Database. =>A database is a collection of.
EXAMPLE I An application showing JDBC access to Cloudscape.
16 Java Database Connectivity. 2 Understand the JDBC Understand the steps of the JDBC: 1.) Importing packages 2.) Opening a connection to a database 3.)
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.
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.
Basics of JDBC.
Objective You will be able to define the basic concepts of object-oriented programming with emphasis on objects and classes by taking notes, seeing examples,
JDBC - Java Database Connectivity. JDBC provides Java applications with access to most database systems via SQL The architecture and API closely resemble.
1 Principles of Database Systems With Internet and Java Applications Today’s Topic Chapter 8: Applications Programming for Relational Databases Instructor’s.
Introduction to JDBC Instructor: Mohamed Eltabakh 1.
SQL pepper. Why SQL File I/O is a great deal of code Optimal file organization and indexing is critical and a great deal of code and theory implementation.
Using Oracle JDBC How to Run JDBC on Your Account Communication Mechanism Using Metadata Building a Database Auto Commit v.s Atomic Transaction.
CS422 Principles of Database Systems JDBC and Embedded SQL Chengyu Sun California State University, Los Angeles.
Java and database. 3 Relational Databases A relational Database consists of a set of simple rectangular tables or relations The column headings are.
JDBC. What is JDBC JDBC is an acronym for –Java Data Base Connectivity. It allows java program to connect to any database.
CS320 Web and Internet Programming Database Access with JDBC Chengyu Sun California State University, Los Angeles.
CS3220 Web and Internet Programming Database Access with JDBC
Java Access to RDB Relational databases (RDBs) dominate today, due to:
JDBC 15-Apr-18.
CS320 Web and Internet Programming Database Access with JDBC
JDBC 21-Aug-18.
HW#4 Making Simple BBS Using JDBC
Prof: Dr. Shu-Ching Chen TA: Sheng Guan
JDBC 15-Nov-18.
Super Market Management
Java Database Connectivity
JDBC Example.
Presentation transcript:

Object-Oriented Software How does it differ from procedural? How is it similar to procedural? Why has it become so popular? Does it replace or supplement procedural? What is the point? Why bother? Is it here to stay or gone tomorrow?

An Object-Oriented Program (OOP) Is composed of a collection of individual units called objects which package data and functionality together, rather than of lists of instructions which act on external data. Each object is capable of: – receiving calls from other objects to run methods, – executing its own methods, and – sending calls to run methods in other objects.

What is an Object in OOP? An object is a software construct that bundles together data (state) and function (behavior) which, taken together, represent an abstraction of a thing, event, service, etc. An object is an instance of a class. A class models a group of things, events, services, etc.; an object models a particular member of that group.

What is in a Class (or Object)? A class contains attributes and methods. Attributes describe state; methods perform actions. Attributes may be Java primitives, or objects (strings, dates, arrays, other objects, etc). Methods may be instance methods, which only work when the class is instantiated as an object, or static methods, which may be used independently of class instantiation.

Objected-Oriented vs. Procedural Both types of language use structured programming logic; the logical architecture of a Java method will resemble that of an ILE RPG procedure. The main difference is macro-architecture: – With OO, logic and data reside together in objects – OO design focuses on object relationships and interactions rather than code block relationships

Java Source and Object Files Compilation Units (.java files) – With a main method – Without a main method Java Bytecode (.class files) – Compilation-level class files – Nested class files

Glazers Interfaces Package What is a Java package? com.glazers.interfaces package Five compilation units: – GetOpenPO – import open POs – GetInterCo – import intercompany transfers – GetOpenCO – import open customer orders – Function – class of static methods – LogMaker – class to make log object

Examples of Java Files Function.java Function.class GetOpenPO.java GetOpenPO.class ImportOpenPO.class

More Examples of Java Files LogMaker.java LogMaker.class LogMaker$PrintEnding.class LogMaker$PrintHeading.class LogMaker$PrintLine.class LogMaker$PrintMethods.class

Integration ETL Program Structure Five Basic Steps – Open log file and database connections – Extract the result set from source system – Transform any data items – Load the data batch in target system – Close log file and database connections

What are the Objects? Log Object Database Connection Objects SQL Statement Objects Result Set Objects BatchInsert Objects String and Date Objects

The Code Environment package com.glazers.interfaces; import java.io.*; import java.sql.*; import java.util.*; import com.ibm.as400.access.*; import com.javaranch.common.GDate; import com.javaranch.common.JDate; import com.glazers.interfaces.*;

GetOpenPO Class and main public class GetOpenPO { public static void main(String args[]) { // Create an ImportOpenPO object ImportOpenPO impObj = new ImportOpenPO();

Full main method // Create an ImportOpenPO object ImportOpenPO impObj = new ImportOpenPO(); // Call the mainLine and receive its return code System.exit(impObj.mainLine(args[0],args[1], args[2],args[3],args[4],args[5]));

Comments // The main method for class GetOpenPO takes six parameters: // 1) Log File Directory Path (ex. Home/JavaApps/Manu) // 2) Oracle Database Name (SCPODEV, SCPOTEST, etc.) // 3) Oracle UserID // 4) Oracle Password // 5) AS/400 UserID // 6) AS/400 Password // After creating an ImportOpenPO object, these parameters are // passed to its mainLine method.

ImportOpenPO Class & mainLine class ImportOpenPO { public int mainLine (String dirPath, String oraSID, String oraUser, String oraPwd, String as400User, String as400Pwd) {

ImportOpenPO Code Structure try [outer try/catch block] [start the log] try [inner try/catch block] open database connections extract result set from source system perform any data transformations load data batch into target system close database connections catch [catch inner exceptions] catch [catch outer exceptions]

Outer try statements try { // Create LogMaker object and begin logging LogMaker log = new LogMaker(dirPath,"OpenPO.log"); log.printHeading("Open PO Import Log"); // If run interactively, display running message System.out.println ("Open PO Import is running");

Inner try block job steps Open database connections Create Sql statement objects Extract the result set Loop throught the result set: – Extract the data items from result set object – Perform any data transformation – Set the data into the batchInsert object Check error table for any rejects – If any rejects, print rejects to log Close result sets and database connections

Connect to the iSeries // Register the AS400 JDBC Driver DriverManager.registerDriver(new AS400JDBCDriver()); // Create a properties object and connect to the database Properties as400Prop = Function.getAS400Prop(as400User,as400Pwd); conn400 = DriverManager.getConnection ("jdbc:as400://GLAZERS",as400Prop);

Connect to Oracle // Load the Oracle JDBC driver Class.forName("oracle.jdbc.driver.OracleDriver"); // Get the Oracle connection string String oraConnStr = Function.getOraConnStr(oraSID,oraUser,oraPwd); // Connect to the database server connOra = DriverManager.getConnection(oraConnStr); connOra.setAutoCommit(false);

Extracting the Result Set // Get the SQL statement to assign to the stmt400 sqlQuery string String sqlQuery = getSQL(); // Create a Statement object (stmt400) stmt400 = conn400.createStatement(); // Execute the SQL Select and obtain the ResultSet object (rs) rs = stmt400.executeQuery(sqlQuery);

The Batch Insert Prepared Statement // Construct the Insert Prepared Statement before entering the loop PreparedStatement sqlInsert = connOra.prepareStatement( "INSERT INTO INTINS_SCHEDRCPTS " + "(item, loc, scheddate, qty, expdate, ponum, " + "startdate, dateship, masterloadid, loadid," + "integration_stamp, integration_jobid)" + "VALUES (?,?,?,?,?,?,?,?,?,?,?,?)");