开发者

Android game score int add in access database through servlet

开发者 https://www.devze.com 2023-02-16 00:41 出处:网络
I am not sure on how 开发者_JS百科to go about this but I have a game which I want to expand further and let the user submit the score with their name.

I am not sure on how 开发者_JS百科to go about this but I have a game which I want to expand further and let the user submit the score with their name.

This will submit the score and name to a servlet which will add the details into an access database.

The score is of an int type.

Would be great if someone could show me how to do this, or point me in the right direction.

Thanks


In Android, just pass score and name as request parameters in URL.

String url = "http://example.com/servlet?score=" + score + "&name=" + URLEncoder.encode(name, "UTF-8");
// Connect the URL.

In the servlet, just access them as request parameters.

int score = Integer.parseInt(request.getParameter("score"));
String name = request.getParameter("name");
// Save them in DB.

See also:

  • Executing a HTTP GET request with HttpClient in Android
  • Servlets info page
  • JDBC tutorial
0

精彩评论

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