How can i connect to the database from vaadin application

Hi, i have created a login page using vaadin framework. now i want to connect to the database. I can connect to the database from a normal java application. My problem is how to connect to the database from that login page. Where i have to write that connection code. Is it possible to write in vaadin application? Please help me as early as possible…
Thanks in advance.

Have you looked at the replies
to your previous post


Which database you need to connect with vaadin. Its same as you did in java. Nothing new in vaadin.
Simply Say, You need Mysql J connector jar file for connect with mysql db. for postgresql jar for postgresql. you can download those jar file depending on your need from their official site. for postgre :: , for mysql ::: or you can see this too :::

sample code :: for mysql

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class JdbcExample2 {

public static void main(String args) {
Connection con = null;

try {
  con = DriverManager.getConnection("jdbc:mysql:///test",
    "root", "secret");

    System.out.println("Successfully connected to " +
      "MySQL server using TCP/IP...");

} catch(Exception e) {
  System.err.println("Exception: " + e.getMessage());
} finally {
  try {
    if(con != null)
  } catch(SQLException e) {}


Note :

you need to copy paste this jar file into either in
jdk/ jre/ lib/ ext
path for netbeans or jre lib ext path or you can put into server lib path(eg. glassfish server). or refer previous forum post. it may help you.


Thank you for giving the idea at right time.