[英]java.lang.IllegalStateException Target host must not be null connecting to database
I am trying to connect to localhost/myfile.php
on my computer. 我正在尝试连接到计算机上的
localhost/myfile.php
。 The PHP file converts database data into JSON
which I want to parse after connecting. 该PHP文件将数据库数据转换为我想要在连接后解析的
JSON
。 When I try to connect, I get 当我尝试连接时,我得到
Target host must not be null, or set in parameters. scheme=null, host=null,
path=10.0.0.9/myfile.php
Any ideas? 有任何想法吗?
public void getData(){
String result = "";
InputStream isr = null;
try{
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("10.0.0.9/myfile.php");
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
isr = entity.getContent();
}
catch(Exception e){
Log.e("log_tag", "Error in http connection "+e.toString());
resultView.setText("Couldnt connect to database" + e);
Looks like you're missing the URI scheme. 好像您缺少URI方案。
Try with new HttpPost("http://10.0.0.9/myfile.php");
尝试使用
new HttpPost("http://10.0.0.9/myfile.php");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.