java - android postgresql database connection error -


i try connect android app postgresql databse doesn't connection dr iver running connection not working.

here java code:

private void initdatabase() {      try {          class.forname("org.postgresql.driver");      } catch (classnotfoundexception e) {          return;      }      connection connection = null;     string url = "jdbc:postgresql://10.0.2.2/seminarkurs";      try {          connection = drivermanager.getconnection(url , "postgres", "postgres");         toast.maketext(getapplicationcontext(), "connection successful!", toast.length_long).show();          connection.close();      } catch (sqlexception e) {          toast.maketext(getapplicationcontext(), "connection failed! check output console", toast.length_long).show();         e.printstacktrace();         return;      }  } 

and here logcat:

01-16 14:40:17.192    8044-8053/com.example.damian.schulkalender e/system﹕ uncaught exception thrown finalizer 01-16 14:40:17.192    8044-8053/com.example.damian.schulkalender e/system﹕ java.lang.nullpointerexception             @ org.postgresql.jdbc2.abstractjdbc2connection.close(abstractjdbc2connection.java:677)             @ org.postgresql.jdbc2.abstractjdbc2connection.finalize(abstractjdbc2connection.java:1036)             @ java.lang.daemons$finalizerdaemon.dofinalize(daemons.java:187)             @ java.lang.daemons$finalizerdaemon.run(daemons.java:170)             @ java.lang.thread.run(thread.java:841) 

i'm sure isn't want hear, it's not reasonable thing try connect directly server-side database mobile device. see question here several times week, , i'm not sure why.

the preferred way create server-side application provides data mobile app via http connection (e.g. rest api).

that said, looks attempt create connection failing. may more info replacing e.printstacktrace() in exception handler use of android logger, can see error in logcat.


Comments

Popular posts from this blog

c - How to retrieve a variable from the Apache configuration inside the module? -

c# - Constructor arguments cannot be passed for interface mocks -

python - malformed header from script index.py Bad header -