4 Replies Latest reply on Aug 9, 2016 8:58 PM by kerrishotts

    Link PostGreSQl to android app

    sawank18707653

      hello,

       

      i want to link my PostgreSQL db to my android app and want to fetch the data from the database. earlier i was using jdbc plugin and also was able to load the jdbc but unable to connect it to postgresql..can anyone help

        • 1. Re: Link PostGreSQl to android app
          VectorP Level 4

          Not sure what you mean with "link to a database".

          If the database is located on your external server, you should use ajax/xhr to make a request to a web service, which handles the request on the server, fetches/writes data and returns something (preferable a json object) to the client.

           

          You were not attempting to use a postGreSql database locally on the client, were you?

          1 person found this helpful
          • 2. Re: Link PostGreSQl to android app
            sawank18707653 Level 1

            i am using cordova-plugin-jdbc and want to connect to the external server also you can refer here cordova-plugin-jdbc

            • 3. Re: Link PostGreSQl to android app
              sawank18707653 Level 1

              i am using cordova-plugin-jdbc and want to connect to the external server also you can refer here cordova-plugin-jdbc

              • 4. Re: Link PostGreSQl to android app
                kerrishotts Adobe Community Professional

                Do. Not. Do. This.

                 

                You should never, ever expose your database to the world in such a manner (it is a huge security risk). Instead, you should create a web service on another application server that then communicates to the database server. The web service should not be a "proxy" to the database server -- that is, I shouldn't be able to craft arbitrary SQL. Instead the web service should accept, validate, and execute commands specific to your application (like createProduct, findCustomerById, etc.). Then your code uses XHR/Sockets to communicate with your web service (over HTTPS!).

                 

                A simple diagram looks like this (and obviously omits a lot of stuff, since it's one line:

                 

                client    ←[→    web service (app server)    ←→    database server]    ([] is the division between the outside world and your internal network)

                 

                All of this requires substantial hardening against security threats, so I'd suggest checking out OWASP's massive site about web application security (OWASP ).

                1 person found this helpful