Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't connect Android to PostgreSQL DB

This is my first post on stackoverflow so hopefully I don't sound too incompetent. I'm having an issue connecting my Android App to a PostgresDB that I created. I used the code from this tutorial http://appliedcoffeetechnology.tumblr.com/post/10657124340. Although I modified the String url ... line to the following: String url = "jdbc:postgresql://192.168.1.101:5556/postgres?user=postgres&password=yeahright"; I followed the other instructions on downloading the JDBC and adding it to the package, I also added the internet permissions line.

I've configured the postgreSQL DB on my Windows 7 machine to allow connections, and even set the incoming connections to "trust" so that the password won't get in the way. I also opened up the 5556 port on the Windows firewall. I can connect to it from my Ubuntu laptop, using the following command: psql 192.168.1.101 -U postgres -p 5556 -d postgres However, when running the Android App (on a real device) I get "java.sql.SQLException: No suitable driver" thrown by the conn = DriverManager.getConnection(url) call.

Thank you greatly in advance for your help, and let me know if I can provide any other useful information.

Craig Ringer below mentioned a web service app. Originally I was hesitant as I didn't want to add an even steeper incline to my learning curve, but I decided to go with Django, and it has been amazingly simple.

like image 368
Lokist Avatar asked Oct 03 '12 04:10

Lokist


1 Answers

AFAIK Android doesn't support JDBC natively. (Update: newer versions do). Honestly, you're WAY better off running a web service and having your Android app communicate with the DB via web service requests.

Search SO for "android postgresql".

Some related discussions:

  • Android OS and postgreSQL
  • How to create webservice in java using apache tomcat using PostgreSQL
  • Driver JDBC PostgreSQL with Android
  • How can I securely (indirectly) query a postgresql database within android?
  • PostgreSQL JDBC connection fails on Android 4.0
like image 138
Craig Ringer Avatar answered Oct 11 '22 01:10

Craig Ringer