Reputation: 5996
In my android application, I want to create and use java web service to connect to remote mysql server. I tried searching for the same but results are vague.
Can anyone please suggest me how can I do following things:
Create a java web service which connects to remote mysql server (without using jdbc)
Publish that service
Use that service to send & receive data in json format
Is all of the above are possible?
Any article/link/code snippet welcomed.
So sample web service would be something like this??
HelloWeb.java
@WebService
public class HelloWeb {
@WebMethod
public String sayGreeting(String name) {
return "Greeting " + name + "!";
}
}
Server.java
public class Server {
public static void main(String[] args) {
Endpoint.publish("http://localhost:9898/HelloWeb", new HelloWeb());
System.out.println("HelloWeb service is ready");
}
}
Upvotes: 0
Views: 2607
Reputation: 464
You need JDBC to connect to MySQL. You can abstract that by using an ORM, but it would still be using JDBC on a lower level.
You can create a REST web service using JAX-RS from here
Upvotes: 2
Reputation: 308743
Like all computer science problems, I'd decompose this one into smaller, more manageable pieces:
You can test each piece independently this way. I think it'll be more reusable, too.
Upvotes: 3