Siddhesh Bhobe Persistent eBusiness Solutions

Slides:



Advertisements
Similar presentations
Exercises of the Tutorial on Advanced Web Programming Authors: Miroslava Mitrovic Dragan Milicev Nino.
Advertisements

Fundamentals, Design, and Implementation, 9/e Chapter 14 JDBC, Java Server Pages, and MySQL.
1 JDBC Java Database Connectivity. 2 c.pdf
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.
XML Technologies and Applications Rajshekhar Sunderraman Department of Computer Science Georgia State University Atlanta, GA 30302
1 Foundations of Software Design Lecture 27: Java Database Programming Marti Hearst Fall 2002.
Session-01. Hibernate Framework ? Why we use Hibernate ?
UFCE4Y UFCE4Y-20-3 Components and Services Julia Dawson.
JDBC / ODBC JDBC is the java API that facilitate interaction of a java application with the DBMS. FIRST APPROACH:
Helena Pomezná, ciz034 St. skupina: L392 FEI, VŠB-TUO Ak. rok. 2002/2003 Download:
Database Management Systems 1 Oracle Programming.
JDBC. What is JDBC JDBC is an acronym for –Java Data Base Connectivity. It allows java/jsp program to connect to any database.
Beginning Databases with JDBC Mike Bradley Adapted from and notes by Kevin Parker, Ph.D.
JDBC. JDBC Drivers JDBC is an alternative to ODBC and ADO that provides database access to programs written in Java.
JDBC and Hibernate Joshua Scotton. Connecting to Relational DBs.
Servlets Database Access. Agenda:  Setup Java Environment  Install Database  Install Database Drivers  Create Table and add records  Accessing a.
Java + XML. Java 2 Enterprise Edition Server Side java Servlets JSP JavaBeans Web Services Database jdbc.
Introduction to JDBC Michelle Lee, Ye Wu & Jeff Offutt SWE 432 Design and Implementation of Software for the Web.
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.
1 JDBC Aum Amriteshwaryai Namah. 2 2 JDBC – Java DataBase Connectivity.
JDBC Enterprise Systems Programming. JDBC  Java Database Connectivity  Database Access Interface provides access to a relational database (by allowing.
Chapter 8 Databases.
PROCESSING AND QUERYING XML 1. ROADMAP Models for Parsing XML Documents XPath Language XQuery Language XML inside DBMSs 2.
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.
JDBC Database Programming in Java Prepared by., Mrs.S.Amudha AP/SWE.
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.
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.
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 Session 14.
Advanced Java Session 5 New York University School of Continuing and Professional Studies.
Web Programming Assistant Professor Xiaozhong Liu
Umair Javed©2005 Enterprise Application Development Java Database Connectivity (JDBC) JDBC1.
JDBC Java and Databases. SWC – JDBC JDBC – Java DataBase Connectivity An API (i.e. a set of classes and methods), for working with databases in.
1 JDBC – Java Database Connectivity CS , Spring 2010.
Intro to JDBC Joseph Sant Applied Computing and Engineering Sciences Sheridan ITAL.
D Copyright © 2004, Oracle. All rights reserved. Using Oracle XML Developer’s Kit.
USING ANDROID WITH THE DOM. Slide 2 Lecture Summary DOM concepts SAX vs DOM parsers Parsing HTTP results The Android DOM implementation.
JDBC Statements The JDBC Statement, CallableStatement, and PreparedStatement interfaces define the methods and properties that enables to send SQL or PL/SQL.
Challenges in XML It’s good… but is it good enough? Siddhesh Bhobe Persistent eBusiness Solutions.
I Copyright © 2004, Oracle. All rights reserved. Introduction.
Database: JDBC Overview
CS3220 Web and Internet Programming Database Access with JDBC
Java Access to RDB Relational databases (RDBs) dominate today, due to:
Lec - 14.
Developing Dynamic Web Pages Without Programming
JDBC – Java Database Connectivity
Web Technologies IT230 Dr Mohamed Habib.
Servlet Fudamentals.
Reflection API, JDBC, Hibernate, RMI
JDBC & Servlet CSE 4504/6504 Lab.
CS320 Web and Internet Programming Database Access with JDBC
Database JDBC Overview CS Programming Languages for Web Applications
HW#4 Making Simple BBS Using JDBC
XML and Databases.
Database Processing with XML
Prof: Dr. Shu-Ching Chen TA: Sheng Guan
Design and Implementation of Software for the Web
Client Access, Queries, Stored Procedures, JDBC
Mr. Harish Sharma Asst. Professor Dept. of CA & IT SGRRITS Dehradun
Interacting with Database
Bolat Azamat, Kim Dongmin
Introduction of Week 11 Return assignment 9-1 Collect assignment 10-1
JDBC Example.
Data Access Layer (Con’t) (Overview)
CS3220 Web and Internet Programming Database Access with JDBC
CS3220 Web and Internet Programming Database Access with JDBC
Processing and Querying XML
Oracle and XML Mingzhu Wei /7/2019.
Presentation transcript:

Siddhesh Bhobe Persistent eBusiness Solutions XML and Databases Siddhesh Bhobe Persistent eBusiness Solutions

Outline of the talk Mapping XML into relational data Generating XML using Java and JDBC Storing XML XML on the Web XML support in Oracle XML API for databases Conclusion

Mapping XML into relational data Generating XML using Java and JDBC Storing XML XML on the Web XML support in Oracle XML API for databases Conclusion

The database We can model the database with a document node and its associated element node: <?xml version=“1.0” ?> <myDatabase> table1 table2 ... tablen </myDatabase> Order of tables is immaterial

The table Each table of the database is represented by an element node with the records as its children: <customer> record1 record2 ... recordm </customer> Again, order of the records is immaterial, since the relational data model defines no ordering on them.

The record A record is also represented by an element node, with its fields as children: <custRec> field1 field2 ... fieldm </custRec> The name is arbitrary, since the relational data model doesn't define a name for a record type

The field A field is represented as an element node with a data node as its only child: <custName type="t"> d </custName> If d is omitted, it means the value of the fields is the empty string. The value of t indicates the type of the value

Example <?xml version=“1.0” ?> <myDatabase> <customers> <custRec> <custName type=“String”>Robert Roberts</custName> <custAge type=“Integer”>25</custAge> </custRec> <custName type=“String”>John Doe</custName> <custAge type=“Integer”>32</custAge> </customers> </myDatabase>

Mapping XML into relational data Generating XML using Java and JDBC Storing XML XML on the Web XML support in Oracle XML API for databases Conclusion

Generating XML from relational data Step 1 : Set up the database connection // Create an instance of the JDBC driver so that it has // a chance to register itself Class.forName(sun.jdbc.odbc.JdbcOdbcDriver).newInstance(); // Create a new database connection. Connection con = DriverManager.getConnection(jdbc:odbc:myData, “”, “”); // Create a statement object that we can execute queries with Statement stmt = con.createStatement();

Generating XML (cont.) Step 2 : Execute the JDBC query String query = “Select Name, Age from Customers”; ResultSet rs = stmt.executeQuery(query);

Generating XML (cont.) Step 3 : Create the XML! StringBuffer xml = “<?xml version=‘1.0’?><myDatabase><customers>”; while (rs.next()) { xml.append(“<custRec><custName>”); xml.append(rs.getString(“Name”)); xml.append(“</custName><custAge>”); xml.append(rs.getInt(“Age”)); xml.append(“</custAge></custRec>”); } xml.append(“</customers></myDatabase>”);

Mapping XML into relational data Generating XML using Java and JDBC Storing XML XML on the Web XML support in Oracle XML API for databases Conclusion

Storing XML in relational tables Step 1 : Set up the parser StringReader stringReader = new StringReader(xmlString); InputSource inputSource = new InputSource(stringReader); DOMParser domParser = new DOMParser(); domParser.parse(inputSource); Document document = domParser.getDocument();

Storing XML (cont.) Step 2 : Read values from parsed XML document NodeList nameList = doc.getElementsByTagName(“custName”); NodeList ageList = doc.getElementsByTagName(“custAge”);

Storing XML (cont.) Step 3 : Set up database connection Class.forName(sun.jdbc.odbc.JdbcOdbcDriver).newInstance(); Connection con = DriverManager.getConnection(jdbc:odbc:myDataBase, “”, “”); Statement stmt = con.createStatement();

Storing XML (cont.) Step 4 : Insert data using appropriate JDBC update query String sql = “INSERT INTO Customers (Name, Age) VALUES (?,?)”; PreparedStatement pstmt = conn.prepareStatement(sql); int size = nameList.getLength(); for (int i = 0; i < size; i++) { pstmt. setString(1, nameList.item(i).getFirstChild().getNodeValue()); pstmt.setInt(2, ageList.item(i).getFirstChild().getNodeValue()); pstmt.executeUpdate(sql); }

Mapping XML into relational data Generating XML using Java and JDBC Storing XML XML on the Web XML support in Oracle XML API for databases Conclusion

XML on the Web (Servlets) public void doGet(HttpServletRequest req, HttpServletResponse resp) { resp.setContentType("text/xml"); PrintWriter out = new PrintWriter(resp.getOutputStream()); … generate XML here, as before… out.println(xmlGenerated); out.flush(); out.close(); } Appropriate XSL can be inserted for display

XML in IE 5.0

Let’s insert the XSL… <?xml version=“1.0” ?> <?xml-stylesheet type="text/xsl" href="http://myServer/Customer.xsl"?> <myDatabase> <customers> <custRec> <custName type=“String”>Robert Roberts</custName> <custAge type=“Integer”>25</custAge> </custRec> … other records here … </customers> </myDatabase>

XML with XSL in IE 5.0

Mapping XML into relational data Generating XML using Java and JDBC Storing XML XML on the Web XML support in Oracle XML API for databases Conclusion

XML support in Oracle Oracle8i and interMedia XML Parsers and XSL Processors (Java, C, C++, and PL/SQL) XML Class Generators (Java and C++) XML SQL Utility for Java XSQL Servlet

Oracle8i and interMedia run Oracle XML components and applications inside the database using JServer - Oracle8i's built-in JVM interMedia Text allows queries such as find "Oracle WITHIN title" where "title" is a section of the XML document

XML Parsers in Oracle

XML Class Generator for Java

XML SQL Utility for Java (Generating XML)

XML SQL Utility for Java (Inserting XML)

XSQL Servlet

Mapping XML into relational data Generating XML using Java and JDBC Storing XML XML on the Web XML support in Oracle XML API for databases Conclusion

XML API for databases Ramnivas Laddad, JavaWorld, Feb 2000 blend the power of a database with the features of XML most XML tools work with the SAX or DOM API implement the same APIs directly over a database, enabling XML tools to treat databases as if they were XML documents. That way, we can obviate the need of converting a database.

XML API with database

Mapping XML into relational data Generating XML using Java and JDBC Storing XML XML on the Web XML support in Oracle XML API for databases Conclusion

Conclusion XML to relational data is easy (?) Lots of tools, support for XML in databases emerging… research, as well as commercial! However, there are still a lot of unresolved issues… we’ll look at them in XML and Challenges.