1

I need to connect my backend in Postgres with GWT, but I am not able to find any suitable tutorial.

Also I have read that I need some kind of web container to do that, but I don't know how?

If anyone could help me with how the connection needs to be created between postgres and GWT and how do I use RPC and the web container that would be great!

A step-by-step answer would really help me understand the basic approach.

I am using Eclipse to code.

Thanks!

lucian.pantelimon
  • 3,673
  • 4
  • 29
  • 46
Prince
  • 20,353
  • 6
  • 39
  • 59
  • Your question is really too general to be answered. You should break it down into smaller pieces so that we can help you with a specific issue. A few hints though: read about web-application architectures (Presentation layer, controller layer, service layer, DAO layer and model layer). Don't expect to learn all at the same time GWT, Servlets, Web-containers, JDBC, Hibernate, Guice in an hour or in a small answer we could provide. – Guillaume Polet Mar 23 '12 at 13:51
  • What I am not understanding is how to communicate between the Postgres database using the RPC mechanism in GWT and a simple example would help me get started. I am using LinkedList to display my CellTable but now I need to use database to display the CellTable and I am not able find any GWT tutorial for the same. – Prince Mar 25 '12 at 16:26
  • It all depends on how you want to proceed with the access to the DB: Raw SQL and JDBC, or something more like JPA? Both approaches have their pros and cons, Raw SQL is usually more performant but harder to maintain and is more error-prone, while JPA is a lot easier to maintain but uses more resources. – Guillaume Polet Mar 26 '12 at 07:18

1 Answers1

2

On the server side in GWT you can work with connection to DataBase as in any other project is not based on the GWT. To do this you can simply use the JDBC driver & use the "Connection" object. For example:

PreparedStatement ps = null;
ResultSet resultSet = null;
ps = connection.prepareStatement("Select * from Users Us");
resultSet = ps.executeQuery();
while (resultSet.next()) {
    //take the field and do something with it. You can take something with construction "resultSet.getInt("Us.id")"
}

If you want to transfer objects , that reflect entity of the database, through RPC to client side, they must implement the interface "Serializable". To work with database objects, you can also use the ORM-systems, such as Hibernate.

Hleb
  • 7,037
  • 12
  • 58
  • 117