简体   繁体   中英

Android cannot connect directly with a Postgres database, and cannot use JDBC connections

I have this problem that my Android app cannot connect directly with a Postgres databse and cannot use JDBC connections. I've browsed the web a bit and some people say, that the best way to deal with this is to run a web service. I'm absolutely lost on how to tackle this problem. Should I build an extension of some sort or... ? Thanks in advance for the help.

It's possible to use JDBC with pgJDBC on newer Android versions, but not a good idea.

See JDBC vs Web Service for Android and Driver JDBC PostgreSQL with Android for why.

Basically, if you're on a device with potentially flakey connectivity, you don't want a persistent connection if you can use stateless HTTP requests instead.

You can never have a direct access to a database which is on a server. For this you need to run some server side code and use JSON to interact your app with server

This tutorial might be of help to you: Connect android with PHP Mysql

And instead of connecting to MYSQL you can connect to PostgreSQL with the help of these docs:

PHP with PostgreSQL

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM