Can you guys point in the direction of either a concept on how I would
do this or a sample project for Ecllipse / GWT that I can go thru.

Keeping in mind I am new at this too.

I can figure most things out with sample code.

My Secario:
I have installed MySQL Database on my PC
Trying to make a GWT application to interact with this Database

In the hope to Base this on the same senario but on a web based
system. i.e. MySQL on a website and the GWT app interacting with this.

Any help would greatly appricated.

Thanks for the help thus far.

Stephan


On Sep 3, 9:44 am, Isaac Truett <[email protected]> wrote:
> Hi,
>
> The problem is that you're trying to mix GWT and java.sql. That's not
> going to work. JS in the browser can't connect to your database.
>
> The cause of your specific error is that Class.forName() is not a part
> of the JRE that GWT emulates.
>
> See also:http://code.google.com/webtoolkit/doc/1.6/RefJreEmulation.html
>
> - Isaac
>
> On Wed, Sep 2, 2009 at 7:21 PM,
>
>
>
> GumbyGWTBeginner<[email protected]> wrote:
>
> > Hi Guys,
>
> > Was wondering if anyone could answer a small question?
>
> >  I have created a class called DBFlow  (Code below) which connects to
> > a MySQL DB and retrieve the number of rows in a DB.
>
> > I am new at this could anyone throw some light on the subject.
>
> > ****************Error Message****************
>
> > [ERROR] Line 51: The method forName(String) is undefined for the type
> > Class
>
> > ****************Code to Call Class****************
>
> >                  DBFlow TestTheDB = new DBFlow();
> >                  TestTheDB.main();
>
> > ****************Class Code****************
>
> > import java.sql.Connection;
> > import java.sql.DriverManager;
> > import java.sql.ResultSet;
> > import java.sql.SQLException;
> > import java.sql.Statement;
> > import java.lang.Class;
> > import com.google.gwt.user.client.Window;
>
> > public class DBFlow {
>
> >        public void onModuleLoad() {
> >                //sdsd
>
> >        }
>
> >        public DBFlow() {
> >                //sdsd
>
> >        }
>
> >        public void main() {
> >                Connection conn = null;
> >                try {
> >                        conn = getConnection();
> >                        String tableName = "family";
> >                        Window.alert("tableName=" + tableName);
> >                        Window.alert("conn=" + conn);
> >                        Window.alert("rowCount=" + countRows(conn, 
> > tableName));
> >                } catch (Exception e) {
> >                        Window.alert("No Connect");
> >                        e.printStackTrace();
> >                        //System.exit(1);  // Edit out as it is an erro
> >                } finally {
> >                        // release database resources
> >                        try {
> >                                conn.close();
> >                        } catch (SQLException e) {
> >                                e.printStackTrace();
> >                        }
> >                }
> >        }
>
> >        public Connection getConnection() throws Exception {
> >                String driver = "com.mysql.jdbc.Driver";
> >                String url = "jdbc:mysql://localhost:3306/dogs";
> >                String username = "root";
> >                String password = "mypass";
>
> >                Class.forName(driver); // load MySQL driver
> > ***************************************Error here apprantly
> >                Connection conn = DriverManager.getConnection(url, username,
> > password);
> >                return conn;
> >        }
>
> >        public int countRows(Connection conn, String tableName) throws
> > SQLException {
> >           // select the number of rows in the table
> >                Statement stmt = null;
> >                ResultSet rs = null;
> >                int rowCount = -1;
> >                try {
> >                        stmt = conn.createStatement();
> >                        rs = stmt.executeQuery("SELECT COUNT(*) FROM " + 
> > tableName);
> >                        // get the number of rows from the result set
> >                        rs.next();
> >                   rowCount = rs.getInt(1);
> >                } finally {
> >                        rs.close();
> >                        stmt.close();
> >                }
> >                return rowCount;
> >        }
>
> > }- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
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