Home » Java Basics » 10 - Java - Database and XML Input
10

Database Applications - Introdiction

Basic overview of how databases work in java

Processing data input from a variety of sources is central to large J2EE applications. Organizations store data in large databases within a commercial DBMS or Database Management System. Enterprise components such as EJBs usually insert, modify, and retrieve data from a database. They simply pass the data onto the appropriate servlet or JSP in a collection object or other appropriate data structure for HTML page construction and HTTP response generation. The thin clients usually receive HTTP requests for data and pass the requests onto enterprise components, and the enterprise component retrieves the data from the database.

Screen Shot 9a: Calling EJB components from Servlets
Screen Shot 9a: Calling EJB components from Servlets

Writing and deploying EJB components is quite complex and explaining it is an entire tutorial in its own right. We will learn more about accessing data via J2EE components by opening a sample fruit database through a servlet and JSP. An MS Access database that holds a simple table named 'fruitlist' has been bundled with this tutorial. Download the fruits.mdb database. Double click on it to open it through MS Access. You will see a single file called 'fruitlist'. In the next exercise, we will access this program from a servlet and a JSP.

Screen Shot 9b: The fruitlist file in the Fruits Database

Note: The image names in column 'image' have upper case extensions. The images themselves have upper case extensions; their names should be identical as the Tomcat server is case sensitive. You will get broken links if image names in the database are not identical case-wise to their names in the filesystem.