Cannot connect Android to PostgreSQL DB

This is my first stackoverflow post, so hopefully I'm not too incompetent. I have a problem connecting my Android application to the PostgresDB that I created. I used the code from this tutorial http://appliedcoffeetechnology.tumblr.com/post/10657124340 . Although I changed the String url string ... as follows: String url = "jdbc:postgresql://192.168.1.101:5556/postgres?user=postgres&password=yeahright"; I followed other instructions for downloading JDBC and adding it to the package, I also added an Internet permission line.

I configured the postgreSQL database on my computer running Windows 7 to allow connections, and even set incoming connections to "trust" so that the password does not interfere. I also opened port 5556 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 I run the Android application (on a real device) I get "java.sql.SQLException: there is no suitable driver" caused by calling conn = DriverManager.getConnection(url) .

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

Craig Ringer mentioned the web service application below. Initially, I hesitated because I didn’t want to add an even steeper addiction to my learning curve, but I decided to go with Django, and it was amazingly simple.

+6
source share
2 answers

AFAIK Android does not support JDBC natively. (Update: newer versions). Honestly, you are better off working with a web service, and your Android application communicates with the database through web service requests.

Find SO for "android postgresql".

Some related discussions:

+3
source

The error message you get indicates that you did not copy jgbd jgbc jgbc into your application.

Having said that, direct SQL connections to a remote database, perhaps even through a 3G network, may not give the desired performance.

If you just need a database in your application to store some materials, you should look at the built-in SQLite database.

+1
source

Source: https://habr.com/ru/post/926804/


All Articles