简体   繁体   中英

Android Client /Java Server and Mysql DataBase Tcp Socket Programming

I have an Android Client which can send a Image to Java server on TCP socket , Java server insert's the Image received into MySQL as a Long Blob and also client ID. Now I want that the Java server to retrieve all the images saved in MySQL for a given client II, and send all the Images to Android client.

Can anyone give an example or any Idea for doing this?

You need to create some API on your server. I would go with the REST JSON API, so that your Android client will make a request to the following URL:

http://yourhost.com/api/images

And the response would be:

[
  {"name":"foo", "url":"http://yourhost.com/foo"}, ...
]

I believe you can achieve that with many Java server-side frameworks, but the idea behind that is: your server receives a request for images, fetches data from DB and writes a response as json/xml/protobuf/whatever your like/.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM