Complete Newbie With Database Questions

Hello everyone. I just started reading the Book of Vaadin and made my first hello world application. I am completely new to Java, Eclipse, and everything else Java-related. I come from the C# desktop development world, so I already understand most of the concepts of using the language, but not the other stuff like servlets and database access. I just got Tomcat installed and have never used it before, so it took me a bit to figure out how to run my first application.

Anyways, I am curious to know how I can connect to a database with Vaadin. Everything I read tells me that you can use your existing knowledge of Java to connect to databases, but since I have none this is completely new for me. In C#, I used ADO.NET and ended up writing my own abstraction layer so that I could make an application work across multiple types of database engines. So is there something I can use with Vaadin that will support multiple types of databases? I have also kind of grown accustomed to the way that Django does things with databases. I think the Ruby on Rails people refer to it as ActiveRecord or something like that.

Any help would be appreciated as I must be the last guy on Earth to learn Java and Eclipse. Everything I read assumes you already know how to work with both and I just started with both yesterday, so please be gentle :slight_smile:

You have a number of options. The most popular choices are probably either using JDBC directly, which means you’ll write your queries yourself, populate your objects manually - well, basically do everything manually. Another option is to use
which is highly popular in the java world. JPA is a standard which defines how object relations should be marked and how the objects should be stored and managed in databases.

The advantage with JPA is that it abstracts away the database layer.You’ll be using an
, which means that you don’t have to care about populating objects manually and keeping track of changes in objects etc. With JPA you can do lots of things quite quickly. Everything comes with a price, in this case the price is that you won’t have as much control of what happens in the database layer and optimising JPA in a complex enterprise size application can be hard.

If you decide to use JPA, I recommend that you take a look at a small framework called Application Foundation I’ve written. One of the things I’ve wanted to achieve with it is to make JPA based persistence easier for Vaadin developers. JPA isn’t exactly meant for statefull applications like Vaadin, so there are a few gotchas you’ll need to know. The Application Foundation contains a persistence module which provides a JPA based persistence to the developer, hiding all the gotchas mentioned. If you are interested, you can get the Application Foundation from
the directory
. Make sure you’ll read the
the documentation of the persistence module
, just to get you started and to see how it is used.