Need Assistance on GWT, Mysql

127 views
Skip to first unread message

kokou.a...@gmail.com

unread,
Dec 24, 2007, 11:12:19 AM12/24/07
to Google Web Toolkit
hello all,

Please I am new into GWT, and there are few Challenges I am facing, I
need your assistance with.

Currently I am developing my applications with GWT. I read many post
but nothing seems going through my head,

Let me start again. I am currently developing an AJAX application into
a webhosting server which is shared. but I am doing everything locally
from My PC and later upload them into a remote server.

what I need to know now is I read about some Mysql Driver which is
JDBC. I went to the java website, but waht I got there was also
confusing. pls direct me to what is the appropriate software shoud I
download. and put into the remote server which is a hosting one. I
don't have the opportunity to chage anything I like there.

and how can I connect the GWT application to interact with mysql?
remember I am also using php/mysql.

please if any one can give me a step by step guide. I read everythig
but it is confusing. I need help

give me explanation in an easy way. specially what is important is
database/ server interactivity to the client browser.

hope to hear from you soon,

thanks

Ian Bambury

unread,
Dec 24, 2007, 11:33:51 AM12/24/07
to Google-We...@googlegroups.com
Hi,
 
To connect to MySQL using PHP: GWT calls the PHP script, and that script connects to MySQL.
 
How to get PHP to connect to MySQL is beyond the scope of this list, but here's an example of a GWT class to connect to PHP
 
import com.google.gwt.core.client.GWT;
import com.google.gwt.http.client.Request;
import com.google.gwt.http.client.RequestBuilder;
import com.google.gwt.http.client.RequestCallback;
import com.google.gwt.http.client.RequestException;
import com.google.gwt.http.client.Response;

public class Server
{
 public static void callPHP(String parameter)
 {
  try
  {
   String parms = "parameter=" + parameter;
   RequestBuilder builder = new RequestBuilder( RequestBuilder.POST, GWT.getModuleBaseURL() + "/php/script.php");
   builder.setHeader("Content-Type", "application/x-www-form-urlencoded");
   builder.sendRequest(parms, callback);
  }
  catch (RequestException e)
  {
  }
 }
 private static RequestCallback callback = new RequestCallback()
 {
  public void onError(Request request, Throwable e)
  {
  }
  public void onResponseReceived(Request request, Response response)
  {
  }
 };
}


--

Ian
--------------------------------------------
http://examples.roughian.com
--------------------------------------------
 

Pavel Byles

unread,
Dec 24, 2007, 11:36:24 AM12/24/07
to Google-We...@googlegroups.com
to interact with any db_server you have to make a rpc connection in your gwt client-side code to the web server.
please read http://code.google.com/webtoolkit/documentation/com.google.gwt.doc.DeveloperGuide.RemoteProcedureCalls.html#MakingACall

then in your server side code you connect to mysql using java.

When connection to Mysql using java you may need something like libmysql-java (if you are using linux) or something of the sort that has the java/mysql driver on the server.

so...
on client: use GWT/RPC mechanism to make asynchronous call to server
on web server: connect to db_server via mysql/java driver
on web server: respond to client

-Pavel

Kokou Afidegnon

unread,
Dec 24, 2007, 12:36:41 PM12/24/07
to Google-We...@googlegroups.com


Thanks for the quick reply, but there is something else I would like to know!

how can I install a java based sql driver since I am using a Shared hosting server. that is my big problem. locally on my PC, I can do anything. but I am working with clients who required AJAX based application, and using gwt, I think it will be more portable and secure for me than trying to hard code the JS script myself.

and many hosting server with its features.

the basic one, the current one I am working with.most of them do not even have a telnet/SSH support where I think things will be  a bit easy.

is there a possibility to install JDBC driver on a shared server that can easilly connect to mysql database and interact with the database Asynchronously? if that is not hte case, do you know any other alternative since I am using GWT , pls any  assistance is gratefully accepted.

thanks

Ian Bambury

unread,
Dec 24, 2007, 12:43:44 PM12/24/07
to Google-We...@googlegroups.com
You can't run Java on the server unless the hoster lets you. Same with MySQL. You have to work with what the hosting service provides
--

Ian
--------------------------------------------
http://examples.roughian.com
http://examples.roughian.com/rxf/
--------------------------------------------

kokou.a...@gmail.com

unread,
Dec 24, 2007, 1:02:06 PM12/24/07
to Google Web Toolkit


On Dec 24, 5:43 pm, "Ian Bambury" <ianbamb...@gmail.com> wrote:
> You can't run Java on the server unless the hoster lets you. Same with
> MySQL. You have to work with what the hosting service provides
>
> On 24/12/2007, Kokou Afidegnon <kokou.afideg...@gmail.com> wrote:
>
>
>
>
>
> > > > Thanks for the quick reply, but there is something else I would like
> > to know!
>
> > how can I install a java based sql driver since I am using a Shared
> > hosting server. that is my big problem. locally on my PC, I can do anything.
> > but I am working with clients who required AJAX based application, and using
> > gwt, I think it will be more portable and secure for me than trying to hard
> > code the JS script myself.
>
> > and many hosting server with its features.
>
> > the basic one, the current one I am working with.most of them do not even
> > have a telnet/SSH support where I think things will be a bit easy.
>
> > is there a possibility to install JDBC driver on a shared server that can
> > easilly connect to mysql database and interact with the database
> > Asynchronously? if that is not hte case, do you know any other alternative
> > since I am using GWT , pls any assistance is gratefully accepted.
>
> > thanks
>
> --
>
> Ian
> --------------------------------------------http://examples.roughian.comhttp://examples.roughian.com/rxf/
> --------------------------------------------

thanks once again, in that case, do you have any suggestion on how to
interact php/mysql with gwt?
on the client machine?

kokou.a...@gmail.com

unread,
Dec 24, 2007, 1:03:07 PM12/24/07
to Google Web Toolkit
or what about a Java Applet?

kokou.a...@gmail.com

unread,
Dec 24, 2007, 1:07:42 PM12/24/07
to Google Web Toolkit
pls you can check on the server information located at :
http://www.realtipper.com/info.php

TomWilsonFL

unread,
Dec 24, 2007, 1:09:44 PM12/24/07
to Google Web Toolkit
> how can I install a java based sql driver since I am using a Shared hosting
> server. that is my big problem. locally on my PC, I can do anything. but I
> am working with clients who required AJAX based application, and using gwt,
> I think it will be more portable and secure for me than trying to hard code
> the JS script myself

> is there a possibility to install JDBC driver on a shared server that can
> easilly connect to mysql database and interact with the database
> Asynchronously? if that is not hte case, do you know any other alternative
> since I am using GWT

Kokou,

I think you are somewhat confused about GWT. I see that you understand
that GWT generates the JavaScript for you, but it doesn't limit you to
using ONLY Java RPCs on the server-side.

You mentioned that your host is PHP/MySQL. You can use GWT to interact
with PHP, which can easily manipulate data from a MySQL DB.

In short:

GWT JAVASCRIPT (Async call) -> PHP (Query DB) -> MySQL (Perform query,
return response) -> PHP (Echo response [true/false for update or
insert success] OR echo results in XML/JSON) -> GWT JAVASCRIPT (Parse
response)

Ian's post above starts you off on how to do this. You do NOT need
JDBC for this solution.

You might want to look here for a sample of a PHP script which returns
JSON results: http://angel.hurtado.googlepages.com/tutorialgwt2

Peace,
Tom

TomWilsonFL

unread,
Dec 24, 2007, 1:14:01 PM12/24/07
to Google Web Toolkit
I see your host has JSON support enabled, which is now built into PHP.

Read the following also:

http://www.php.net/manual/en/ref.json.php

http://www.php.net/manual/en/ref.mysqli.php

On Dec 24, 1:07 pm, "kokou.afideg...@gmail.com"

kokou.a...@gmail.com

unread,
Dec 24, 2007, 2:36:33 PM12/24/07
to Google Web Toolkit
Pls Another question again!

please how can I locate the path of Mysql driver here: from the server
information at http://www.realtipper.com/info.php

thanks

TomWilsonFL

unread,
Dec 24, 2007, 2:44:17 PM12/24/07
to Google Web Toolkit
This is getting to be off the topic of this forum I fear, but you need
to get this "driver" talk out of your head.

You simply need to write a PHP script on the server, and have GWT call
the script. MySQL is already installed and PHP can talk to it already.
You do NOT need any drivers.

In PHP, you will simply write similar code to this:

<?php
mysql_connect("hostname", "username", "password");
mysql_select_db("my_schema");

$resultSet = mysql_query("SELECT * FROM testTable");

if (mysql_num_rows($resultSet)) {
while ($data = mysql_fetch_assoc($resultSet)) {
$return_array[] = $data;
}
}

return json_encode($return_array);
?>

HTH

On Dec 24, 2:36 pm, "kokou.afideg...@gmail.com"

kokou.a...@gmail.com

unread,
Dec 24, 2007, 2:56:36 PM12/24/07
to Google Web Toolkit
Thanks very much. let me work with the info I get so far.

kokou.a...@gmail.com

unread,
Dec 24, 2007, 3:44:08 PM12/24/07
to Google Web Toolkit
Hello,

Another odd question I would like to ask again!

can't we do anything without the ODBC or JDBC driver? since we have
mysql already. what difference will it make when they are or not
connected?

Thanks

Reinier Zwitserloot

unread,
Dec 24, 2007, 4:07:48 PM12/24/07
to Google Web Toolkit
Sigh. You don't understand it at all. Please review the entire thread.

A short review:

GWT CAN NOT INTERFACE WITH A DB *AT ALL*.

GWT can, however, interface with your server. Which runs, well,
anything. PHP. Ruby on Rails. Django. Python. Servlets. Whatever you
like. In your case, it looks like your hosting provider has made this
choice for you, and it has to be PHP. Which doesn't need a mysql
driver; it has support for some random unknown subset of mysql built
right in, and to know exactly what you can and can't do, you'll need
to ask elsewhere, as that has nothing to do with GWT.

Your PHP program can thus interface with the MySQL DB; it serves as a
'bridge' between GWT (which runs on your user's computers and can only
talk to your server, not to any database), and your database (which
runs only on your server's computer and can not talk to your users).

ODBC is a microsoft windows thing, and it's completely unrelated.
Forget it.

JDBC is a way for a JAVA SERVER to talk to a DB. You can't run a java
server on your hosting platform, JDBC is therefore completely and
utterly unrelated to what you're trying to do. Forget it.

If you misunderstand anything written in this entire thread... reread
it, I guess. We can't say it any clearer than this.

On Dec 24, 9:44 pm, "kokou.afideg...@gmail.com"

kokou.a...@gmail.com

unread,
Dec 28, 2007, 4:19:19 AM12/28/07
to Google Web Toolkit
Helllo good morning

pls I have a few contribution to make in line of the tutorial posted
at:

http://angel.hurtado.googlepages.com/tutorialgwt2

I just discover we can use mysql_pconnect in order to have persistent
database connection and I think it will be good for Ajax based
application since we are working on asynchronous data.

you may review this for more. and let me have your feedback.

check on

http://www.php.net/mysql_pconnect

and also,

http://www.php.net/manual/en/features.persistent-connections.php

thanks in advance.
Reply all
Reply to author
Forward
0 new messages