Hello, JDO


Hello, JDO!

The TestJDOHelper program is simple. Listing 6-2 in Chapter 6 shows the one class, TestJDOHelper, found in the com.ysoft.jdo.book.factory package.

The program takes one command line parameter that names the properties file configured for the selected JDO implementation. The main method of the class loads the properties from the file and then calls the getPersistenceManagerFactory method in JDOHelper. For more information about getting a persistence manager factory from JDOHelper, see Chapter 6. After verifying that a persistence manager can be obtained from the persistence manager factory, the program ends.

The properties file that specifies the factory settings varies with the implementation used. For the reference implementation, the properties file is jdori.properties, located at com/ysoft/jdo/book/factory/jdori. The build copies it to factory.properties at build/com/ysoft/jdo/book/factory. If you are using one of the three mentioned commercial implementations, you will have to edit the appropriate file to configure the JDBC connection. When using the Kodo implementation, you must also add a valid license key to the properties file. The reference implementation does not use JDBC and does not require a license key.

Building and Running the TestJDOHelper Program

To build the TestJDOHelper program, go to the bookants directory and type ant testjdohelper. This build is part of the ant learning-programs build. Listing 8-2 shows some of the expected output when using the reference implementation.

Listing 8-2: Expected Output from Running ant testjdohelper

start example
 testjdohelper:     [javac] Compiling 1 source file to E:\Bookcode\build      [echo] creating runTestJDOHelper.bat      [echo] Running TestJDOHelper      [java] -- listing properties --      [java] javax.jdo.option.RestoreValues=false      [java] javax.jdo.option.ConnectionURL=fostore:FOStoreTestDB      [java] javax.jdo.option.Optimistic=false      [java] javax.jdo.option.ConnectionUserName=JDO      [java] javax.jdo.option.ConnectionPassword=book      [java] javax.jdo.option.NontransactionalWrite=false      [java] javax.jdo.PersistenceManagerFactoryClass=                   com.sun.jdori.fostore.FOStorePMF      [java] javax.jdo.option.NontransactionalRead=false      [java] javax.jdo.option.IgnoreCache=false      [java] javax.jdo.option.RetainValues=false      [java] javax.jdo.option.Multithreaded=false      [java] Got the PMF okay      [echo] created runTestJDOHelper.bat BUILD SUCCESSFUL 
end example

Notice that the build creates the runTestJDOHelper batch file. The batch file can be used to run the test again. All generated batch files are placed in the bookcode-home directory. The TestJDOHelper program has no user interface. It runs to completion in a matter of seconds.

As soon as you can get TestJDOHelper to build and run, you have successfully completed the steps necessary to use the remaining client-server programs in this chapter and the next. Chapters 10 and 11 provide additional instructions for the configuration needed to build examples that deploy in the Tomcat and JBoss containers.




Using and Understanding Java Data Objects
Using and Understanding Java Data Objects
ISBN: 1590590430
EAN: 2147483647
Year: 2005
Pages: 156
Authors: David Ezzio

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net