Postgre connection to Vaadin23

How can i implement this code written by Alejandro Duarte? Seems like BeanItemContainer and BeanFieldGroup are not working? https://vaadin.com/blog/building-a-web-ui-for-postgresql-databases

This Tutorial is 7 years old. Nothing of this should ever be used nowadays. You can follow any recent tutorial about database connection available on the docs, the different database dialect doesn’t interfere with it normally.

I am new to vaadin. I also dont know how to code yet it.

Im actually following this one. However, I do not know how to show the results on the vaadin ui.

I recommend just learning about how to work with Vaadin first, then. Using data from a database is not significantly different from using just normal in-memory data for a UI, but dealing with the database while learning will just make things slightly more difficult for you.

Or, in other words, learn to build the UI you want with the data disconnected from the components. Once you can do that, plugging in the data from a database should be trivial, assuming you can read data from the database.

I actually understand the tutorial on connecting database from the sample data.sql written in vaadin tutorial. However, I do not know how to show the data to the UI from a localhost postgre database. I also have the db connected and running with the UI. Does it have somwthing to do with repository or service java files?

You need to be more specific. Which part exactly are you having problems with? If you ignore the database for a second, are you able to show data in the UI?

If im using the sample data.sql, yes i am able to show the data.

What I want to show is the data from my localhost postgres database.

url is correct: jdbc:postgresql://localhost:5432/mydatabase

You still need to be more specific.

What is the exact problem you’re facing?

Is the connection failing?

I dont think the connection is failing. Im not getting the errors i received before like pw authentication failed or database does not exist.

I dont know how to show the data from my localhost database to my ui. :pensive:

I am sorry for this.

Can you query the database with jdbc and print something to System.out?

I would encourage you to think of the problem at hand as two separate steps:

  1. How to read data from a database and place it in Java objects
  2. How to display data from Java objects in a Vaadin UI
    Once you understand how to do one of those steps, the second one becomes much more easy.