views:

159

answers:

3

Hello guys

so i am just getting to terms with using gwt and the rpc services that i can implement.

So i began with the gwt greeting service started project.(all gwt users know this starter app) all i wanted to do was to press the send button on the web page. it would retrieve a simple string from my database and display it on the webpage.

within the greeting service implmentation which is on the server side i call this code

public String greetServer(String input) throws IllegalArgumentException {
  Connection conn = null;
  Statement statement = null;
  ResultSet rs = null;

  String data = "error";


  try {
   data = "error 1";
   conn = (Connection) DriverManager.getConnection("jdbc:mysql://localhost/newtest?" +
   "user=root");
   data = "error 2";

   statement = (Statement) conn.createStatement();


   rs = statement.executeQuery("SELECT * FROM  example_autoincrement");
   rs.next();
   data = rs.getString("data");

   } catch (SQLException ex) {
    System.out.println("SQLException: " + ex.getMessage()); System.out.println("SQLState: " + ex.getSQLState());
   }

   return data;
}

when i run this code in an application that is not server side. it runs and prints out a simple string with no errors.

when run it in a gwt application i get this error

SQLException: Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. 
The driver has not received any packets from the server.
SQLState: 08S01

also data is what is sent back to the client and the reply is error 1. so i understand that the error is occuring at

conn = (Connection) DriverManager.getConnection("jdbc:mysql://localhost/newtest?" +   "user=root");

this line

A: 

i found this problem when i printed the stack trace..... any ideas on how to resolve it

Caused by: java.security.AccessControlException: access denied (java.net.SocketPermission localhost resolve)

molleman
A: 

u just need to add a jar file for Driver.. it will work fine ,in my case i used ojdbc14.jar, i think for mysql there is mysql-connector.jar ...

namrata chikhle
A: 

u just need to add a jar file for Driver.. it will work fine ,in my case i used ojdbc14.jar, i think for mysql there is mysql-connector.jar ...

namrata chikhle