2.7. Prepare Event Records to Populate the Database


This web project uses H2 for data storage by default. H2 is a Java database integrated with the application servers of JBoss EAP 6.x. It is an in-memory database which means that the data does not persist once the application using the database stops running. For this reason, seed data must be stored in a file within the project and added to the database each time the application starts. While it might not seem practical to have to construct the database each time the application starts, this type of data storage is useful during development for testing purposes.

Warning

The use of H2 for data storage is for testing purposes only and must not be used during production.
The procedure below demonstrates preparing two sample Event records for addition to the H2 database once the TicketMonster application starts.

Procedure 2.7. Prepare Event Records

  1. In the Project Explorer view, expand ticket-monsterJava Resourcessrc/main/resources.
  2. Double-click the import.sql file to open it for editing.
  3. Double-click the import.sql view label to make the editor fill the window.
  4. Create a new Event record by copying the following on one line after the existing Member record
    insert into Event (id, name, description, major, picture, version) values (1, 'Shane''s Sock Puppets', 'This critically acclaimed masterpiece...', true, 'http://dl.dropbox.com/u/65660684/640px-Carnival_Puppets.jpg', 1);
  5. Create a second new Event record by copying the following on one line after the first new Event record
    insert into Event (id, name, description, major, picture, version) values (2, 'Rock concert of the decade', 'Get ready to rock...', true, 'http://dl.dropbox.com/u/65660684/640px-Weir%2C_Bob_(2007)_2.jpg', 1);
    The import.sql file contains the two new Event records.

    Figure 2.12. Content of the import.sql File for this TicketMonster Workflow

  6. Save the import.sql file.
  7. Double-click the import.sql view label to make the editor return to its previous size.
Red Hat logoGithubRedditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

© 2024 Red Hat, Inc.