postgresql - How can I access my localhost from my Android device -
how can access localhost android device using fedora 21 , me android device nexus 5, can explain me step step path of connection. article [postgresql not connecting android using jdbc throwing org.postgresql.util.psqlexception: connection attempt failed
i change file: pg_hba.conf
# ipv4 local connections: host 10.0.2.2 trust
postgresql.conf:
listen_addresses = '*' # ip address(es) listen on; # comma-separated list of addresses; # defaults 'localhost'; use '*' # (change requires restart) port = 5432 # (change requires restart) max_connections = 100
but not me....
it's me java - jdbc source:
@override protected void doinbackground(void... arg0){ try { log.d("start connection","start connection"); string url = "jdbc:postgresql://" + "10.0.2.2" + ":" + "5432/keen"; string user = "keen"; string pass = "q1w2e3"; log.d("row 10","row 10"); class.forname("org.postgresql.driver").newinstance(); log.d("row 20","row 20"); connection conn = drivermanager.getconnection(url, user, pass); log.d("connection successfully","connection successfully"); statement stmt = conn.createstatement(); string sql = "create table test (id bigserial primary key);"; stmt.executeupdate(sql); conn.close(); } catch (classnotfoundexception e) { log.d("connection fail","connection fail"); } catch (sqlexception e) { log.d("connection fail","connection fail"); } catch (exception e) { log.d("connection fail","connection fail"); } return null; } }
it's me logcat output:
04-23 15:52:23.645 15749-15749/com.gorbin.androidsocialnetworksextended.keen i/google maps android api﹕ google play services package version: 7329438 04-23 15:52:23.843 15749-15927/com.gorbin.androidsocialnetworksextended.keen d/start connection﹕ start connection 04-23 15:52:23.844 15749-15927/com.gorbin.androidsocialnetworksextended.keen d/row 10﹕ row 10 04-23 15:52:23.847 15749-15927/com.gorbin.androidsocialnetworksextended.keen d/row 20﹕ row 20 04-23 15:53:19.118 15749-15767/com.gorbin.androidsocialnetworksextended.keen w/system.err﹕ org.postgresql.util.psqlexception: connection 10.0.3.2:5432 refused. check hostname , port correct , postmaster accepting tcp/ip connections. 04-23 15:53:19.134 15749-15767/com.gorbin.androidsocialnetworksextended.keen i/art﹕ system.exit called, status: 0 04-23 15:53:19.134 15749-15767/com.gorbin.androidsocialnetworksextended.keen i/androidruntime﹕ vm exiting result code 0, cleanup skipped.
it show crashing between row 20 connection @ getconnection().
thanks.