Data Access

E. Reed Doke, Bill C. Hardgrave, Richard A. Johnson · Cambridge University Press eBooks · 2004

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.

Read the paper · More papers on PaperTik