I want to get the data of a database table to the client end. I'm sending the data via a JSON. When I print the output result in the client end it gives the following result.
{"pricing":null}
When I print return statement in the server end, it outputs the following
[Connection.Pricing@3d5bae2]
There are no errors. What have I done wrong?
Here is my Client Side Code
public String loadTable(String tablename) throws ClientProtocolException, IOException {
pathParams.add("tablename", tablename);
ClientResponse response = service.path("access").path("loadtable").queryParams(pathParams).type(MediaType.APPLICATION_JSON).get(ClientResponse.class);
String responseString = response.getEntity(String.class);
return responseString;
This is my Server End
@Path("/loadtable")
@GET
@Produces(MediaType.APPLICATION_JSON)
public List<Pricing> loadTable(@QueryParam("tablename") String tablename) throws Exception {
List<Pricing> pricing = new ArrayList<Pricing>();
try {
query = c.prepareStatement("select * from " + tablename);
ResultSet ets_rs = query.executeQuery();
while (ets_rs.next()) {
pricing.add(new Pricing(ets_rs.getString(1), ets_rs.getString(2), ets_rs.getString(3), ets_rs.getString(4), ets_rs.getString(5), ets_rs.getString(6)));
}
query.close();
} catch (Exception e) {
e.printStackTrace();
} finally {
if (c != null) {
c.close();
}
}
return pricing;
Here is my POJO class in the server end
@XmlRootElement
class Pricing {
String category;
String lower_limit;
String class_no;
String value;
String employee;
String upper_limit;
public Pricing() {
}
Pricing(String a, String b, String c, String d, String e, String f) {
category = a;
lower_limit = b;
upper_limit = c;
class_no = d;
value = e;
employee = f;
}
//getters
}