如何从Android应用程序访问Oracle数据库。 [英] How to access Oracle Data Base from Android Application.

查看:398
本文介绍了如何从Android应用程序访问Oracle数据库。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Android应用程序将在数据库服务器从显示的外部数据库(Oracle)的数据。它可以是可能只有 Web服务(REST风格),所以我决定发展中的Java / Java EE的本身就是一个Web服务。
我不想去与PHP或其他一些technologies.Pls建议我继续这样。

Android application which will show data from external Data Base(Oracle) in the database server .It can be possible only with web services(RESTful),so i decided to develop a web services in Java/Java EE itself. I dont want go with PHP or some other technologies.Pls suggest me to proceed this.

推荐答案

依赖于Web服务。难道仅仅是RESTful的XML? JAX-WS? JSON? Etc.Either方式,它应该是为呼唤与HTTP套接字,并解析响应一样简单。

Depends on the web service. Is it just RESTful XML? JAX-WS? JSON? Etc.Either way it should be as easy as calling out with an HTTP socket and parsing the response.

要创建一个Web服务按照下面的链接

To create a web-service follow the below link

REST Web服务

使用了HTTPClient

using Using HTTPClient

public static String hitService(String host, int port, String path, String postBody) throws IOException {
        HttpHost target = new HttpHost(host, port);
        HttpClient client = new DefaultHttpClient();
        HttpGet get = new HttpGet(path);
        HttpEntity results = null;
        try {
            HttpResponse response=client.execute(target, get);
            results = response.getEntity();
            return EntityUtils.toString(results);
        } catch (Exception e) {
            throw new RuntimeException("Web Service Failure");
        } finally {
            if (results!=null)
                try {
                    results.consumeContent();
                } catch (IOException e) {
                    // empty, Checked exception but don't care
                }
        }
    }

Android的食谱例如

这篇关于如何从Android应用程序访问Oracle数据库。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆