Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your profile (name, country/region, and company) is displayed to the public and will accompany any content you post. You may update your IBM account at any time.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

Use an XML database in PHP and Java applications

Understand the benefits of using a native XML database

Tyler Anderson (tyleranderson5@yahoo.com), Freelance writer and developer, Backstop Media
Tyler Anderson has graduated with a degree in computer science in 2004 and a Master of Science degree in computer engineering in December, 2005, both from Brigham Young University. Tyler is currently a freelance writer and developer for Backstop Media.

Summary:  Native XML databases have grown in popularity along with XML, because data is stored as native XML, rather than through tables in a traditional database. Using a native XML database means that a change to the schema requires minimal changes to your code and no change to the database. PHP and Java ™developers can benefit greatly from using native XML databases. In this tutorial, you will get quickly up to speed using a native XML database and see how to use it to benefit XML development.

Date:  25 Mar 2008
Level:  Intermediate PDF:  A4 and Letter (1511 KB)Get Adobe® Reader®

Activity:  43669 views
Comments:  

Before you start

This tutorial is recommended for Java and PHP developers who use XML and want to explore the benefits of native XML databases (IBM® DB2® Express-C 9.5 in this tutorial). Although it is helpful to have some knowledge of PHP and Java programming, it isn't necessary to follow along and learn from this tutorial. Knowledge of the XML DOM is also helpful.

About this tutorial

Frequently used acronyms

  • DOM: Document Object Model
  • HTML: Hypertext Markup Language
  • HTTP: Hypertext Transfer Protocol
  • JDK: Java Development Kit
  • PHP: PHP: Hypertext Preprocessor
  • SDK: Software development kit
  • XML: Extensible Markup Language

This tutorial shows you how to reduce development time with a native XML database. As an illustration, you will change an existing XML schema, and see these changes in the code also. Developers will learn the common necessities for working with a native XML database in both PHP and Java technologies, including how to:

  • Connect to the database (DB2 Express-C 9.5)
  • Store and retrieve XML data
    • Create a form that writes new data to the database
    • Create a form that reads existing data from the database
  • Query the database using SQL/XML
    • Enhance the data viewers to support a quick search function
  • Modify the database schema
    • Make database changes unnecessary!

To learn and implement the above concepts, you'll create several Web applications where users can enter and view patient data in PHP code, and then enter and view doctor data in Java code.


Prerequisites

Beyond a text editor and a browser, you'll need the tools necessary to support Java and PHP servers:

  • Java JDK, the latest JDK from Sun to run and compile Java code. This tutorial uses version Java 6 update 5.
  • Apache Tomcat, the Web server that will host your Java applications. This tutorial uses version 6.0.16.
  • PHP, the latest version of PHP, 5.2.5 at the time of this writing.
  • Apache2, the Apache2 HTTP server that is the recommended HTTP server for PHP.
  • Operating System, any will do. This tutorial was written on a machine running Windows Vista® Ultimate.
  • DB2 Express-C 9.5, the database used for this tutorial. You can use any native XML database such as Apache Xindice instead.

1 of 10 | Next

Comments



static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=XML, Information Management, Java technology, Open source
ArticleID=296102
TutorialTitle=Use an XML database in PHP and Java applications
publish-date=03252008
author1-email=tyleranderson5@yahoo.com
author1-email-cc=dwxed@us.ibm.com