开发者

mysql error with GWT

i am trying to create an sample apps using GWT and my code is below

public void onModuleLoad() {
  VerticalPanel panel = new VerticalPanel();
  MultiWordSuggestOracle oracle = new MultiWordSuggestOracle();
  database data=new database();
     Statement s1;
    try {
        s1 = data.conn.createStatement();
         s1.executeQuery ("SELECT * FROM details LIMIT 10");
           ResultSet rs = s1.getResultSet ();
 开发者_StackOverflow社区          while (rs.next ())
           {


               String name = rs.getString ("name");
               oracle.add(name);
           }
    } catch (SQLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }


    SuggestBox suggestbox = new SuggestBox(oracle);
    panel.add(new Label("Enter Country"));
    panel.add(suggestbox);
    panel.addStyleName("demo-panel-padded");
    RootPanel.get("demo").add(panel);

} and i have added the mysql-bin.jar connector in war/WEB_INF/lib/ and now i am getting an compilation error

17:39:52.353 [ERROR] [a] Line 28: No source code is available for type java.sql.Statement; did you forget to inherit a required module?

i need to know why i am getting this error and how can i rectify it


You cannot use server-side code (java.sql.* in your case) in GWT client side modules.

You should make an RPC call to the server. The server callback should fetch the data from your database, and send it back to your GWT client.


Using Eclipse with the google plugin, you can create a new "Web Application Project". More information about the plugin can be found here: http://code.google.com/eclipse/

You will get a simple project that contains a GreetingService which receives a String from the client side and responds with "Hello" + string. For your example you would have to add the code that reads from the DB in the GreetingServiceImpl class and then use the response (which can be a String[] containing the name read from DB) on the client side to populate the SuggestionBox

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜