Blog

SQLContainer 1.0 Released

By  
Sami Ekblad
·
On Jan 21, 2011 12:37:00 PM
·

Good news for everyone using SQL databses in their Vaadin applications. The Vaadin SQLContainer is end-of-beta and v 1.0 has been released today.

The SQLContainer is an add-on for Vaadin, that implements the Container interface for standard SQL database servers. SQLContainer allows you to easily bind data stored from an SQL database to Table and Select components, as well as edit the data using Forms. Compared to many object-relational tools this provides you a fast, low-level database access.

Simple to use

Like other add-ons, download the add-on from Directory and follow the add-on installation instructions. Note that the SQLContainer is a server-side component and no widgetset compilation is needed.

Also, getting started with SQL data-bound components is easy. The most typical scenario is to use a Table to present data from a SQL query:

try {
    connectionPool = new SimpleJDBCConnectionPool(
            "org.hsqldb.jdbc.JDBCDriver",
            "jdbc:hsqldb:mem:sqlcontainer", "SA", "", 2, 2);
    SQLContainer container = new SQLContainer(new FreeformQuery(
            "SELECT * FROM people", Arrays.asList("ID"), connectionPool));
    Table table = new Table("People", container);
} catch (SQLException e) {
    // Handle error
    e.printStackTrace();
}

 

Two modes of operation are supported: FreeformQuery and TableQuery.

Next, take a look at the SQLContainer Tutorial to see how to use this full-featured SQL helper in your applications. For example, if you have started to write your application using the IndexedContainer, you can follow these instructions to convert your application to use an SQL database back-end.

The SQLContainer is to replace the old QueryContainer in Vaadin and from now on you should never use the QueryContainer anymore. The replacement should be easy as you can see from the SQLContainer example above.

And oh yes, here is a very simple online demo application where you see the SQLContainer in action.

 

Sami Ekblad
Sami Ekblad is one of the original members of the Vaadin team. He is now working as a framework advocate, and you can find many add-ons and code samples to help you get started with Vaadin. Follow at – @samiekblad
Other posts by Sami Ekblad