• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Help please with GWT Sql Connection ...

 
Greenhorn
Posts: 3
Google Web Toolkit Netbeans IDE Eclipse IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry for my bad english !

Hello, I'm new in java tehnologies ... I begin to study java GWT tehnology , help me please how to make connection to my sql server in my gwt application ... I don't know what to utilise Ecliplse or Netbeans ( i know that in eclipse existing gwt designer and i can very easy set to my gwt elements beatiful font , but i can not make connection to my sql server ... i read on the diverse forums that in eclipse with appengine cannot to connect sql database , in don't know it's true or not )
Give me please a little example how i can do it ! don't interesting eclipse or netbeans ... i need to do a project but i have a little time ...



Thanks !!!

P.S
please if you can send source code project to :
my skype - grindays
yahoo ID [email protected]
 
Rancher
Posts: 436
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome!

GWT Java code is compiled to JavaScript. The result runs in the client's browser. It can't create an SQL connection.

You need some server-side component that does this and some means of communication between the two. The server-side component can be anything, like a PHP application, a Ruby on Rails application or some Java application. The communication between client and server can be easy when you use Java; GWT comes with a custom RPC servlet that lets you send Java objects back and forth between client and server. If your server faciliates some other language/basis, a good way to choose would be REST with XML or JSon. (In fact it may even be a good idea when your server is Java based.)

On the server side you use the framework's or language's capabilities for SQL databse access as usual.
 
Valex World
Greenhorn
Posts: 3
Google Web Toolkit Netbeans IDE Eclipse IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Hauke Ingmar Schmidt wrote:Welcome!

GWT Java code is compiled to JavaScript. The result runs in the client's browser. It can't create an SQL connection.

You need some server-side component that does this and some means of communication between the two. The server-side component can be anything, like a PHP application, a Ruby on Rails application or some Java application. The communication between client and server can be easy when you use Java; GWT comes with a custom RPC servlet that lets you send Java objects back and forth between client and server. If your server faciliates some other language/basis, a good way to choose would be REST with XML or JSon. (In fact it may even be a good idea when your server is Java based.)

On the server side you use the framework's or language's capabilities for SQL databse access as usual.




Thanks for you reply !!!
I know that , i read about this ... but you can give me an little exemple with Rpc way ? if you can to create a project where you make this connect ... i lose 5 days ... and i don't solve my problem ... can you help ?
 
Hauke Ingmar Schmidt
Rancher
Posts: 436
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Valex Id wrote:
Thanks for you reply !!!
I know that , i read about this ... but you can give me an little exemple with Rpc way ? if you can to create a project where you make this connect ... i lose 5 days ... and i don't solve my problem ... can you help ?



I can try to help.

But I don't even know your prerequisites. How does your server side look like?

For an introduction into GWT-RPC take a look here.
 
Valex World
Greenhorn
Posts: 3
Google Web Toolkit Netbeans IDE Eclipse IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Hauke Ingmar Schmidt wrote:

Valex Id wrote:
Thanks for you reply !!!
I know that , i read about this ... but you can give me an little exemple with Rpc way ? if you can to create a project where you make this connect ... i lose 5 days ... and i don't solve my problem ... can you help ?



I can try to help.

But I don't even know your prerequisites. How does your server side look like?

For an introduction into GWT-RPC take a look here.




I have local MySql server, I'm using Netbeans(with Tomcat ) and Eclipse ( in Eclipse i'm using appengine web server, I dont know how to set Tomcat for GWT applications... ) . If you can show me an example where you connect to the Mysql server with RPC, then I will set my sql parametres and try to connect to my server ....

Thanks ... !


 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Valex Id wrote:



Please check your private messages for an important administrative matter.
 
Maneesh Godbole
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Valex Id wrote:
I have local MySql server, I'm using Netbeans(with Tomcat ) and Eclipse ( in Eclipse i'm using appengine web server, I dont know how to set Tomcat for GWT applications... ) . If you can show me an example where you connect to the Mysql server with RPC, then I will set my sql parametres and try to connect to my server ....

Thanks ... !




Since you already have eclipse, I would suggest following the GWT-RPC tutorial Hauke already provided. With the eclipse plugin, you can get a read made, ready to run project.
Once you achieve this, you will notice the server side class which you need to focus on is the xxxImpl.
Do you know how to write code which will open a connection and interact with the DB? If not you can start here https://coderanch.com/how-to/java/JdbcFaq

Essentially, you will need a class which talks to the DB.
This class should provide convenient methods to access the DB data.
From your xxxImpl you will need to invoke these methods and return the serialized data to the client.

In your original post you mentioned GAE. It is true, if you host your application to the gae jpa. However, you can always host your GWT app on tomcat and connect to the DB of your choice
 
Hauke Ingmar Schmidt
Rancher
Posts: 436
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Maneesh Godbole wrote:In your original post you mentioned GAE.



Oh. I am sorry, you did.

It is true, if you host your application to the gae jpa. However, you can always host your GWT app on tomcat and connect to the DB of your choice



Maneesh is right, with GAE you can't use a SQL database. The provided datastore (BigTable) is different to SQL in some important aspects and needs different approaches; the JPA and JDO interfaces can't hide this (and they are not the best fit, especially JPA was made with a relational model in mind).

Sorry for misleading you a bit.

With GAE the setup is easy, an example RPC is provided, tutorials for data access "the GAE way" are provided at the GAE site. But no easy SQL integration there.

But whether you use GAE or not, this has not much to do with GWT. You can't use every feature of every persistence framework when sending objects to the GWT client, e.g. lazy loading will break. So you need to take care of what you send.
 
Maneesh Godbole
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Hauke Ingmar Schmidt wrote:
.... You can't use every feature of every persistence framework when sending objects to the GWT client, e.g. lazy loading will break. So you need to take care of what you send.



I am not sure I understand you clearly here.
Ideally the persistence mechanism should be transparent to the client. As long as the client performs its data communication with the server, using serialized POJOs which can be translated to JS, all should be smooth sailing.
 
Hauke Ingmar Schmidt
Rancher
Posts: 436
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Maneesh Godbole wrote:

Hauke Ingmar Schmidt wrote:
.... You can't use every feature of every persistence framework when sending objects to the GWT client, e.g. lazy loading will break. So you need to take care of what you send.



I am not sure I understand you clearly here.
Ideally the persistence mechanism should be transparent to the client. As long as the client performs its data communication with the server, using serialized POJOs which can be translated to JS, all should be smooth sailing.



If you use lazy loading e.g. in Hibernate, you don't get the POJOs but proxies with references to the entity manager and session. Dependent data (references) will not be fetched when the original object is constructed but at first access. This works fine with server-side frameworks, but does break with GWT.
 
Maneesh Godbole
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh! My bad. I mentally blocked myself into thinking GWT LazyPanel while reading about lazy loading! Duh!

Yes you are correct. However, this is one of the possible workarounds http://hibernate4gwt.sourceforge.net/hibernate_gwt_lazy_issue.html
 
Forget Steve. Look at this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic