Setting up the Database


by jGuru

[Exercise | API Docs | Short Course| Exercises]

Help is available for each task.



    Task 1

    Choose a database system appropriate for your environment and then either install or build the database system with the music data that you prefer.


    Sun's J2EE Reference Implementation comes with a built-in version of the Cloudscape RDBMS. If you are using J2EE RI, you should initially use Cloudscape as your database to avoid configuration problems. You can learn how to substitute a different database after you become comfortable with creating and deploying applications using Cloudscape.

    If you insist on initially using a database other than Cloudscape, you should carefully read and follow the instructions in the following J2EE RI documentation before you begin:

    Note that Microsoft Access doesn't provide adequate SQL support for the tasks required by EJB technology servers.

    For Cloudscape, simply copy the MusicStoreDB.jar archive into the directory %J2EE_HOME%\cloudscape and then unjar the database. (All files unjar into the directory MusicStoreDB within the current working directory.)

    For other database environments, simply compile and run the programs MusicCDCreateTables.java and MusicCDInsertRecords.java after creating an empty database. You can modify the source for the appropriate driver and URL values, or supply them as command-line options. You can also perform these tasks using DatabaseTool, or JDBCTest (TestTool) from the Sun's JDBC area.

    One last step is needed when running with J2EE RI: You need to modify the %J2EE_HOME%\config\default.properties file to define the datasources available to J2EE RI. This is done by changing the line that reads:

    jdbc.datasources=jdbc/Cloudscape|
      jdbc:cloudscape:rmi:CloudscapeDB;create=true
    

    (with everything on one line)

    to be:

    jdbc.datasources=jdbc/Cloudscape|
      jdbc:cloudscape:rmi:CloudscapeDB;create=true|
      jdbc/MusicStore|jdbc:cloudscape:rmi:MusicStoreDB;create=false
    

    (with everything on one line)

    and then restarting both Cloudscape and J2EE RI.

    Barnes and Noble and other sites provide easy access to music CD data such a UPCs, if you want to customize the MusicCD database with your own entries.

    Task 2

    Verify the integrity of the database using a vendor-supplied graphical tool or the DatabaseTool.java program provided.


    See the expected output in this exercise for example output for the Cloudscape View tool and for DatabaseTool.java.

Copyright 1996-2000 jGuru.com. All Rights Reserved.