Book contents
- Frontmatter
- Contents
- Preface
- Introduction
- Chapter 1 Why You Should Learn Java
- Chapter 2 An Introduction to Object-Oriented Programming
- Chapter 3 Java Structure
- Chapter 4 Defining Data
- Chapter 5 Computation
- Chapter 6 Decision Making
- Chapter 7 Loops
- Chapter 8 Arrays
- Chapter 9 Data Access
- Chapter 10 Graphical User Interfaces
- Chapter 11 Object-Oriented Development Issues
- Glossary
- Index
Chapter 9 - Data Access
Published online by Cambridge University Press: 26 August 2009
- Frontmatter
- Contents
- Preface
- Introduction
- Chapter 1 Why You Should Learn Java
- Chapter 2 An Introduction to Object-Oriented Programming
- Chapter 3 Java Structure
- Chapter 4 Defining Data
- Chapter 5 Computation
- Chapter 6 Decision Making
- Chapter 7 Loops
- Chapter 8 Arrays
- Chapter 9 Data Access
- Chapter 10 Graphical User Interfaces
- Chapter 11 Object-Oriented Development Issues
- Glossary
- Index
Summary
OBJECTIVES
In this chapter you will study:
Object persistence;
Sequential file access;
SQL database access;
Object serialization; and
Network access.
This chapter introduces you to Java data access techniques using classes supplied in three packages: java. io, java. sql, and java. net. You are undoubtedly familiar with reading and writing files using COBOL. Java, however, takes a somewhat different approach, and therefore you will not find the clear parallels between COBOL and Java in this chapter that you have seen in the previous chapters.
Here we develop programs to demonstrate sequential file input-output (I-O) and database access. In addition we demonstrate a technique called object serialization used by Java to store intact objects in files for later retrieval. Although a demonstration of network access is beyond the scope of this book, we will present an overview.
The chapter begins with a brief description of the I-O classes contained in the java. io package and their hierarchy. Then, a relatively simple sequential file I-O demonstration is presented. Next we repeat the example using a relational database. Object persistence is then discussed and illustrated using Java's Object Serialization classes. The chapter concludes with a discussion of network access using classes in the java. net package.
- Type
- Chapter
- Information
- COBOL Programmers Swing with Java , pp. 173 - 196Publisher: Cambridge University PressPrint publication year: 2004