GWT and JDBC/MySQL integration framework

101 views
Skip to first unread message

joster

unread,
Aug 30, 2007, 8:59:22 PM8/30/07
to Google Web Toolkit
Hello-

This question is not directly GWT-specific but more on the integration
aspects. Most developers use JDBC/MySQL combination for integration
with back-end server side code.

Now, the JDBC code required to execute SQL statements tend to get very
bloated. While JDBC is a powerful, low level API for accessing and
manipulating a myriad of SQL databases1, it is so low level that it
requires:
1. Writing verbose finally blocks to close database connections
2. Writing catch blocks for all checked exceptions, even if they can't
be reasonably recovered from
3. Adding clumsy if else or switch statements that examine SQLState or
error code values to determine the type of exception generated
4. Writing custom connection or connection pooling code

I am wondering what kind of integration frameworks others are using to
effectively integrate JDBC/MySQL combination for back-end server side
code with GWT-client code-base.

Any wrapper class and/or pointers to address this is highly
appreciated.

Joster

Nathan Williams

unread,
Aug 30, 2007, 10:07:40 PM8/30/07
to Google Web Toolkit
You might want to look at Spring JDBC or iBATIS.

charlie...@gmail.com

unread,
Aug 31, 2007, 9:12:10 AM8/31/07
to Google Web Toolkit
iBatis, Hibernate, JDO, or better yet some JPA implementation such as
Hibernate-JPA or Toplink.

Search the forums here, there are several examples of people using JPA
on the backend of a GWT app. And, all over the interwebs you will
find many good examples of JPA in general (http://java.sun.com/
developer/technicalArticles/J2EE/jpa/).

joster

unread,
Aug 31, 2007, 10:44:21 AM8/31/07
to Google Web Toolkit
Thanks Nathan and Charlie. Appreciate your help.

There seem to be multiple frameworks, has someone done any comparisons
between multiple frameworks and outlined pros/cons of each. And/or
know any external links which provides info on this.

Moreover digging into this forum, it looks like there are known issues
in integrating Hibernate backend with GWT. Will GWT 1.5 (future)
release ease things up? And/or are there technical problems within GWT
which prevents from having a seamless integration.

Joster


On Aug 31, 6:12 am, "charlie.coll...@gmail.com"

krispy

unread,
Aug 31, 2007, 10:54:59 AM8/31/07
to Google Web Toolkit
joster,

GWT is a client side technology, for the most part. You can use any
server side technology you want - the only thing GWT requires for its
own RPC mechanism is a servlet (but you can use a different RPC
mechanism if desired). Many people use Hibernate without a hitch -
the only problems occur when you try and send Hibernate objects to
GWT, which is usually very bad design to begin with. GWT really could
care less about the back end components you use, so there are no known
"issues" between it and GWT - the only problems you will have are the
ones you create for yourself! A lot of people seem to get mixed up
about this stuff - GWT has no relation to JDBC or database
technologies, except insofar as GWT can use data and a database can
provide it - they are no more coupled than Javascript is to MySQL.
Make sense?

-krispy

joster

unread,
Aug 31, 2007, 11:00:27 AM8/31/07
to Google Web Toolkit
Hi Krispy-

Thanks. Appreciate your comments. I am able to better understand.

Could you please elaborate on your comment "the only problems occur


when you try and send Hibernate objects to GWT, which is usually very
bad design to begin with."

What should the correct design look like? Should there be a DTO class
which will take care of mapping Hibernate objects to DTO class,
serialize them and send it back to client?

Joster

noon

unread,
Aug 31, 2007, 11:32:44 AM8/31/07
to Google Web Toolkit
Hello Joster,

For information, I wrote a small article about Hibernate and GWT
cohabitation issues : http://hibernate4gwt.sourceforge.net/hibernate_gwt_problem.html
About the DTO design, the convesion between Hibernate entities and DTO
is not as simple as you may think, especially if you are dealing with
partially loaded objects (filled with Hibernate proxies).

Hope this helps !
Bruno

joster

unread,
Aug 31, 2007, 12:32:18 PM8/31/07
to Google Web Toolkit
Thanks Bruno.

Do you know if anything is being done in the upcoming GWT 1.5 release
to help with issues you have highlighted in your package
(hibernate4gwt)? Most large web-apps do interact with a database
server - having a solid integration framework which works seamlessly
with GWT (client-side technology) will immensely useful to many.

Joster

noon

unread,
Sep 2, 2007, 3:01:26 PM9/2/07
to Google Web Toolkit
Hello Joster,

The only goal of GWT 1.5 is Java 5 support, with no additional feature
such as proxy support or JRE enhancement.
IMHO, the integration of GWT (a client-side, presentation library)
with a server library such as Hibernate or JPA, is out of scope for
both teams. That's the reason why I wrote hibernate4gwt, and will try
to make it as seamless as possible.

Regards
Bruno

ross

unread,
Sep 2, 2007, 3:37:40 PM9/2/07
to Google Web Toolkit
I'm using JDBC/mysql as a backend for my GWT app and I wouldn't
discount using this so quickly. Sure, there may be a whole bunch of
"frameworks" out there that can help - I haven't tried any of them so
I cannot comment. I prefer to have maximum control, which you can
have my writing your own connection pooling code (not hard) and making
calls to database access class from your RemoteServerServlets.
Ofcourse, depending on the scale of your application this may not be
appropriate and you may need more sophisticated frameworks... but I
just wanted to say the RemoteServerServlet -> jdbc access class
approach is not so bad and pretty efficient =)
Reply all
Reply to author
Forward
0 new messages