如何连接到Web服务与远程数据库? [英] How to connect to a Remote Database with Webservices?

查看:155
本文介绍了如何连接到Web服务与远程数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Android应用程序。我需要连接到远程D.B.在网上。所有我知道的是,我必须使用Web服务,安装在远程数据库服务器上。

I have an android APP. I need to connect to a remote D.B. on the internet. All i know is that i have to use a Web Service, installed on the remote DB server.

蒙山我的Andr​​oid应用我必须连接到Web服务,Web服务将执行逻辑运算,以从DB的necesary数据并且将它们发送给我。

Whith my Android APP i have to connect to the web service, and the web service will do the logical operations to get the necesary data from the D.B. and will send them to me.

确定,Web服务是不是一个问题,我有一个朋友,将做到这一点(我不知道关于Web服务),但我不知道我怎么都与Web服务了连接,并且还我不知道怎么也得是Web服务的功能。

OK, the web service is not a problem, i have a friend that will do it (i have no idea about web services), but i dont know how i have to do the connexion with the Web Services, and also i dont know how have to be the functions of the Web Service.

我需要做选择的,让我多行的信息,并选择,那么我将数据发送到web服务(的参数中选择并插入),我supose它只是调用与正常参数的web服务的功能?或者它比这更辛苦?我已经寻找了告诉我这样做,对谷歌的教程,但我不能找到一个很好的教程,展示了如何做到这一点?

有人可以给我一点帮助?例如,一个很好的教程,适合初学者Android的连接到远程数据库与web服务?

can someone give me a little help? for example, a good tutorial for beginners connecting android to a remote DB with webservices?

感谢

推荐答案

您可以使用下面的code连接到网络和获取数据为字符串,可能的数据发送给您的将是JSON形式或XML您可以解析。

You can connect to the web using the below code and get the data as a string,probably data send to you will be in the form of JSON or XML which you can parse.

至于如何连接到Web服务只是给你所连接的URL和传递参数。
字符串urlstr =www.yoursite.com/api.php?parameter1 =+参数1 +&放大器;参数2 =+参数2;

Regarding how to connect to the webservice just give the url that your are connecting to and pass parameters.
String urlstr = "www.yoursite.com/api.php?parameter1="+parameter1+"&parameter2="+parameter2;

     URL updateURL = new URL(urlstr);  
                 URLConnection conn = updateURL.openConnection();  
                InputStream is = conn.getInputStream();  
                 BufferedInputStream bis = new BufferedInputStream(is);  
                 ByteArrayBuffer baf = new ByteArrayBuffer(100);  

                 int current = 0;  
                while((current = bis.read()) != -1){  
                     baf.append((byte)current);  
                }  


                String  html = new String(baf.toByteArray()); 

链接可以给一个明确的想法,如何ü可以在你的应用程序中使用互联网的数据。

this link might give a clear idea as to how u can use internet data in your application.

这篇关于如何连接到Web服务与远程数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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