Learn Java for Web Development

(Tina Meador) #1
CHAPTER 8: Play with Java and Scala 381

Now when you test the URL http://localhost:9000/, you will see the page shown in Figure 8-25.


Figure 8-25. Applying a script on the default database


When you defined the database connection to connect to the H2 database, it did not automatically
create the schema, in other words, the tables and column definitions. To create the schema, Play 2
generates a SQL script and demands to run it: “Apply this script now.” Once you run this script by
clicking the “Apply this script now” button, you can test the URL http://localhost:9000/books
and the new book, as illustrated in Figure 8 -2 6.


Figure 8-26. Adding a book

Free download pdf