Can you make an app that connects to a postgresql database? [closed]

0

Hi, I would like to know if I can make a connection to a postgresql database in the app I am doing with android studio. Thanks

    
asked by Sr. J 13.09.2017 в 10:01
source

1 answer

3

Well, this is not a strict answer to your question, it's more suggestions:

You can connect to a database PostgreSQL via JDBC for Android . But my suggestion is that you try not to use JDBC directly from the Android device . You'll save yourself a lot of trouble.

1. Disadvantages of connecting directly to a DB

Basically, if the connection is made from a device with bad connectivity, it is not recommended to make a persistent connection, instead you should use requests HTTP without status ( stateless HTTP requests ).

That is, web services, in this way we can provide CRUD services.

Other disadvantages:

  • The connection pool through various Android devices makes monitoring difficult and the ability to limit them.

  • The results sent from the DB to android will consume a lot of width band and battery power.

  • Exposing your database directly to the client has risks of security .

2. Benefits of a web service.

The main benefits of a web service:

  • You have short-duration connections with a minimum status , so it's easy to go back to where you were when the device switched from WiFi to mobile network and vice versa (since it briefly drops connectivity) ).

  • They can go through most web proxies

3. Recommendation

Write your database logic in a application server accessible from the web and communicate with that application server through HTTP + JSON, SOAP, XML-RPC or similar. This will do much more efficient the use of bandwidth and the application will be more tolerant to problems with connectivity.

Also saves you from having to expose your database server directly to the Internet - which really should not be a concern with PostgreSQL today (as long as you use SSL), but it's better not to take any chances to do it.

    
answered by 13.09.2017 / 11:48
source