What is the best and most secure way to access a remote MySQL database?

I am about to develop a cloud application in java

, I have a Linux web server installed withmysql

so I come up with two different ways to query the database, both solutions exchange data http requests

and both methods have their own advantages and disadvantages.

I am using below example to demonstrate solutions

database on server

-- fruit--
name    price
Apple     10
Banana     5
Mango      4

      

will say that I want to get all fruits from the database

Solution 1 : write a database access class with PHP

server side help and let java app send request via http requst
ex: - java app will send request SELECT * FROM fruit

then server side PHP

will return request result in `JSON 'format

- it is super reusable and can be used for any future cloud database access and it is clean code because all implementations are not included aside java

except the database access

Solution 2 : write the classes of the Fruit class and the database server side and let the application java

call server side functions via http

requests
it asgetAllFruits()


- this way I have to implement all DAO classes on the server side and this is more coding, less reuse in another project, since DAO is implemented in PHP, maintenance support is higher than solution 1

I think solution 1 is the best because of the usability and simplicity, I am afraid that the database query will be sent via a http

query that does not feel good to me, so I really appreciate your ideas and comments as I am new to such applications if you have any other solutions or advantages and disadvantages I am also open to these

Also I was wondering how other companies are implementing it

+3
java database php mysql cloud


source to share


No one has answered this question yet

See similar questions:

five
Best way to access remote database: via webservice or direct DB access?

or similar:

1256
What are the options for storing hierarchical data in a relational database?
1086
How to connect to MySQL database in Python?
802
How to quickly rename MySQL database (change schema name)?
769
How to get the sizes of MySQL database tables?
704
What's the best collation for MySQL with PHP?
652
What are the best practices for SQLite on Android?
596
What's the best way to filter a Java collection?
587
In Java, what is the best way to determine the size of an object?
399
Best way to store password in database
256
What's the best strategy for unit testing database driven applications?



All Articles
Loading...
X
Show
Funny
Dev
Pics