Persistence
This directory contains the examples from the Persistence chapter, and covers both
Java Object Serialization and JDBC. The JDBC examples are currently coded to make use of
the InstantDB database that ships with the book, but nothing
prevents you (aside from having to create the schema and the data, of course) from using
your own local RDBMS implementation and JDBC driver--the code should port with no problems.
(If you do run into a problem, please email me.)
The following code from the chapter is part of the javageeks.com library:
Which leaves the following code to be found in this directory:
-
CompressedSerialization.java:
-
SecureSerialization.java:
-
CustomSerialization.java:
-
Evolution.java:
-
Replacement.java:
-
sample.prp: The Properties file used by InstantDB. Don't edit without
first reading the InstantDB documentation.
-
CreateSchema.java and
LoadClass.java:
Utilities used to create the schema for the following JDBC examples and to load classes into
the database. If you use a different JDBC instance instead of the InstantDB instance supplied
with this code, make sure to change the JDBC URLs and run the CreateSchema class to create the
expected schema.
-
RemoteStorageClient.java and
RemoteObjectFactoryClient.java:
Clients to the RemoteObjectFactory and RemoteStorageService; this code is identical to the code
found in the javageeks.com library, except for the package names.
-
TPHClient.java: An example demonstrating how ClassLoaders will
be called when a class loaded using a ClassLoader in turn depends on another class: TPHClient
uses a JDBCClassLoader to load the TwoPartHello class, which in turn depends on the OtherPart
class, both of which are found in TwoPartHello.java file,
and must be loaded into the database. Be sure to erase the compiled .class files for
TwoPartHello and OtherPart, or the AppClassLoader will pick them up and the load will always
succeed, even if the database is down.