Reputation: 1124
I want to know how can I pass a parameter to the Rest url and use that parameter to get data from database.
Upvotes: 0
Views: 988
Reputation: 6158
You may use query param to pass the parameter and than process it i am giving u a very simple hints.
@GET
@Produces( { "application/xml", "application/json" })
@Path("getDataFromDB")
public ResponseConverter getDataFromDB(
@QueryParam("recordId") Integer recordId) {
// process with recordId.
}
It will work for you if any doubts let me know.
Upvotes: 1
Reputation: 15453
You can send the JDBC properties in matrix parameters or request parameters. But this practice is very unrecommended.
By doing this you will become venerable in leaking out your info. But for beginner you can do this.
Example:
@Path("connect")
public class DBResource {
@GET
@Path("/{url}/{port}/{userId}/{password}")
public void getConnection(@PathParam("url") String url,
@PathParam("port") String port,
@PathParam("userId") String userId,
@MatrixParam("password") String password) {
... // make the connection string
}
}
Upvotes: 0
Reputation: 587
try to read this link, its very usefull and also have the example with source code and jars, it will take little time to read but you will get your answer.
http://www.vogella.de/articles/REST/article.html
Upvotes: 0
Reputation: 12366
Here is how you can extract parameters from request in Jersey: http://jersey.java.net/nonav/documentation/latest/user-guide.html#d4e253
Upvotes: 0