Book Image

Vaadin 7 Cookbook

Book Image

Vaadin 7 Cookbook

Overview of this book

Table of Contents (19 chapters)
Vaadin 7 Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Accessing a database with Spring


We will make a simple application that adds new orders to the database. A user just fills in a name of the order and clicks on the Add New Order button.

The orders will be stored in the in-memory database and it will be easy to switch the database, for example to MySQL. For accessing the database, we use JdbcTempate from Spring framework.

Getting ready

Create a new Maven project from the Vaadin archetype.

mvn archetype:generate \
 -DarchetypeGroupId=com.vaadin \
 -DarchetypeArtifactId=vaadin-archetype-application \
 -DarchetypeVersion=LATEST \
 -Dpackaging=war \
 -DgroupId=com.app \
 -DartifactId=vaadin-spring-database \
 -Dversion=1.0

The project structure will be as follows:

How to do it...

Carry out the following steps, in order to create a Vaadin application with access to the database with Spring framework:

  1. Add the necessary dependencies to the Maven pom.xml file.

    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring...