Thanks for the help guys. I just want to say that I am quite new to
this and I am basically using the concepts I have learned from
personal reading and all. I am still at the point where most of the
time before I can be able to understand how to write and implement
code, I have to have a look at atleast one fully functional example in
order to understand a concept. That is why in the beginning I made a
request as to anyone who knows where I can get a simple but functional
example that explains in some detail how to build an application and
deploy it on a server together with and run it against a database
especially mysql. I dont mind it even if it is a book that I have to
buy.

On Sep 1, 10:53 am, Abel B <[EMAIL PROTECTED]> wrote:
> Hey,
>
> Here is some of the code that I had written for the application based
> on a mysql test database with one table that has three fields (id,
> firstname, lastname). The name of the project is library application.
>
> for the server side, this is the code that I wrote for
> LibraryServiceImpl
>
> /*
>  * LibraryServiceImpl.java
>  *
>  * Created on 30 August 2008, 15:51
>  *
>  * To change this template, choose Tools | Template Manager
>  * and open the template in the editor.
>  */
>
> package org.silica.library.test.server;
>
> import com.google.gwt.user.server.rpc.RemoteServiceServlet;
> import java.sql.Connection;
> import java.sql.PreparedStatement;
> import java.sql.ResultSet;
> import java.sql.SQLException;
> import javax.naming.InitialContext;
> import javax.naming.NamingException;
> import javax.sql.DataSource;
> import org.silica.library.test.client.Library;
> import org.silica.library.test.client.LibraryService;
> import com.google.gwt.user.client.rpc.InvocationException;
> /**
>  *
>  * @author Administrator
>  */
>
> public class LibraryServiceImpl extends RemoteServiceServlet
> implements LibraryService {
>         private static final String QUERY = "select * from authors
> where id=2";
>
>         public Library getAuthor() {
>         DataSource ds = getDataSource();
>         Library author = null;
>         try {
>                 Connection conn = ds.getConnection();
>                 PreparedStatement ps = conn.prepareStatement(QUERY);
>                 ResultSet results = ps.executeQuery();
>                 while (results.next()) {
>                         author = new Library();
>
>                         author.setId(results.getInt("id"));
>                         author.setFname(results.getString("firstname"));
>                         author.setLname(results.getString("lastname"));
>                 }
>                 conn.close();
>                 return author;
>                 } catch (SQLException e){
>                 throw new InvocationException("Exeption querying database",e);
>                 }
>         }
>
>         private static DataSource getDataSource(){
>                 InitialContext ctx;
>                 try {
>                         ctx = new InitialContext();
>                         return 
> (DataSource)ctx.lookup("java:comp/env/jdbc/MyDataSource");
>                 } catch (NamingException e) {
>                         throw new InvocationException("Exception getting 
> datasoure",e);
>                 }
>         }
>
> }
>
> The following is my client side code
>
> 1)
> /*
>  * Library.java
>  */
> package org.silica.library.test.client;
>
> import com.google.gwt.user.client.rpc.IsSerializable;
>
> public class Library implements IsSerializable {
>         private int id;
>         private String fname;
>         private String lname;
>
>         public void setId(int id) {
>                 this.id = id;
>         }
>
>         public int getId() {
>                 return id;
>         }
>
>         public void setFname(String fname) {
>                 this.fname = fname;
>         }
>
>         public String getFname() {
>                 return lname;
>         }
>
>         public void setLname(String lname) {
>                 this.lname = lname;
>         }
>
>         public String getLname() {
>                 return lname;
>         }
>
> }
>
> 2)
>
> /*
>  * LibraryService.java
>  *
>  * Created on 30 August 2008, 15:51
>  *
>  * To change this template, choose Tools | Template Manager
>  * and open the template in the editor.
>  */
>
> package org.silica.library.test.client;
>
> import com.google.gwt.user.client.rpc.RemoteService;
>
> public interface LibraryService extends RemoteService{
>     public Library getAuthor();
>
> }
>
> 3)
> /*
>  * LibraryServiceAsync.java
>  *
>  */
>
> package org.silica.library.test.client;
>
> import com.google.gwt.user.client.rpc.AsyncCallback;
>
> public interface LibraryServiceAsync {
>     public void getAuthor(AsyncCallback callback);
>
> }
>
> Based on this code how can I be able to display the id, firstname and
> lastname fields of the db simply to atleast show that I can get stuff
> from a db and render it?
>
> On Sep 1, 2:18 am, "Jim Freeze" <[EMAIL PROTECTED]> wrote:
>
> > On Sun, Aug 31, 2008 at 3:43 AM, Abel B <[EMAIL PROTECTED]> wrote:
>
> > > Hi, I am new to both the java language and gwt. I have been reading on
> > > the language for a few months and I have a grasp on some of the most
> > > important concepts.
>
> > > I have been having a hard time rendering data on a browser aftre
> > > making server side calls to a mysql db. I have read about using remote
> > > procedure calls on the server side and then using the entry point
> > > class to render the info retrieved from the application service.
>
> > > Is there anyone who knows where I can get a step by step guide on
> > > working withCRUDfunctions and rendering them on the browser using
> > > gwt. I'm at a loss on what im doing wrong.
>
> > I use RequestBuilder and format the response data with json.
> > It's actually very straightforward.
>
> > Where exactly are you having problems?
> > Can you show us some code that isn't working?
>
> > --
> > Jim Freeze

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to