When I call the web service, it returns this exception to me: java.net.SocketException Allowed. I do not know that this is really a problem. I do not know how to solve this?
home.java page:
try { url = new URL("http://localhost/TraderLevels/subscriber.php"); conn = (HttpURLConnection) url.openConnection(); dis = conn.getInputStream(); } catch (Exception e) { e.printStackTrace(); }
subscriber.php
$username="root"; $password=""; $database="mydb"; $server="localhost"; $connection = mysql_connect($server,$username,$password); if (!$connection) { die('Not connected : ' . mysql_error()); } $db_selected = mysql_select_db($database, $connection); if (!$db_selected) { die('Can\'t use db : ' . mysql_error()); } $query="SELECT * from user"; $result = mysql_query($query); $dom = new DOMDocument('1.0','UTF-8'); $dnode = $dom->createElement('usesssrdetails'); $docNode = $dom->appendChild($dnode); $result = mysql_query($query); $rowNo=1; while ($row = @mysql_fetch_assoc($result)) { $node = $dom->createElement('user'); $categoryNode = $docNode->appendChild($node); $idNode = $dom->createElement('userid',($row['userID'])); $categoryNode->appendChild($idNode); $idNode = $dom->createElement('email',($row['email'])); $categoryNode->appendChild($idNode); $rowNo=$rowNo+1; } $kmlOutput = $dom->saveXML(); echo $kmlOutput; ?>
Update:
I solved the above problem by adding the code below to the manifest.
< uses-permission android:name="android.permission.INTERNET" />
But I got one more exception: java.net.ConnectException: localhost / 127.0.0.1: 80 - Connection refused.
Please tell me how to avoid this problem.
source share