伙计们,我在网址中有一个数据库,例如:www.myurl.com/mydb。
我需要连接到这个db(mydb)如何连接到这个?
URL url = new URL("http://myurl.com/mydb");
URLConnection ucon = url.openConnection();
ucon.connect();
我认为以上用于连接到网址
请帮忙。
答案 0 :(得分:1)
String httpResponse = null;
BufferedReader rd = null;
StringBuilder sb = null;
String line = null;
try
{
URL url = new URL("http://myurl.com/mydb");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.connect();
rd = new BufferedReader(new InputStreamReader(connection.getInputStream()));
sb = new StringBuilder();
while ((line = rd.readLine()) != null)
{
sb.append(line + '\n');
}
// Response is stored here.
httpResponse = sb.toString();
}
catch (Exception e){}
答案 1 :(得分:0)
您显然需要Web-Services
来操纵数据库中的数据。