Hey,
You are going on wrong way! You can only use java.util and java.lang
on client side code ... for everything else you will have to use
server side code which returns results to you client.


On Sep 3, 4:21 am, GumbyGWTBeginner <stephan.gump...@gmail.com> 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;
>         }
>
> }

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to