The easiest way to use PostgreSQL in your Vaadin project is to include it when generating a starter project from Vaadin Start. You can do this by following the steps below:
In Vaadin Start, select the SETTINGS tab.
Scroll down until you see the Technology section.
Select PostgreSQL as the Database.
Now the generated project includes the necessary configurations to connect to PostgreSQL. Specifically, the generated project contains the following dependency inside the
<dependency> <groupId>org.postgresql</groupId> <artifactId>postgresql</artifactId> </dependency>
The generated project also contains the following PostgreSQL configuration added to the
# PostgreSQL configuration. spring.datasource.url = jdbc:postgresql://localhost:5432/postgres spring.datasource.username = postgres spring.datasource.password = password spring.jpa.hibernate.ddl-auto = update
The generated PostgreSQL configuration assumes common defaults for the
password. If your PostgreSQL instance was set up differently, then you should match the properties in the
application.properties file to the appropriate properties from your database instance.
Don’t Store Sensitive Information in a Project’s Properties File
It’s bad practice to store database URI, username, and passwords in the
Now, when you start the application, you should see the following line in your IDE console.
Database available at 'jdbc:postgresql://localhost:5432/postgres'
For an existing Vaadin project, you can connect to PostgreSQL by adding the previously mentioned PostgreSQL dependency to the
pom.xml file. Then you’d add the previously mentioned PostgreSQL configuration to the