I am using oracle db and weblogic as web server.
From my android app i am able to send parameters to my remote server..
My PROBLEM is HOW TO GET THE RESULT SET GENERATED BY MY QUERY FROM MY SERVER TO MY ANDROID APP???
I would be very grateful if someone sites me some examples of doing it…
String result = "";
//the year data to send
ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("year","1980"));
//http post
try{
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://example.com/getAllPeopleBornAfter.php");
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpclient.execute(httppost);
}
The code given below is my jsp page…
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@page import="java.util.*,java.sql.*"%>
<%!
Connection con;
PreparedStatement ps;
String uname,pass;
ResultSet rs;
%>
<%
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl","pro","pro");
ps=con.prepareStatement("select * from login_stud");
rs=ps.executeQuery();
}
catch(Exception e)
{
e.printStackTrace();
}
%>
I want my android app to retrieve the result set ‘rs’….and display it on the mobile screen…how to do that.???. if you want details abut my app u can ask me @dldnh
The best thing you can do is to implement JSON with a RESTFUL Web Service.
More info:
JSON.ORG
How to create a JSON response
Android includes JSON classes such as JSONArray, JSONObject that can be used to interpret the response the Web Service will return. See more at here.
You can’t go wrong. JSON is fast, there are ways to secure the communication if you implement RESTFUL Authentication.
Best of all your Web Service will be compatible with iOS Apps and any other platform with JSON support.
Good luck!