0

I am making a Java small program for some myself and some friends that we will use to work on projects together.

The program relies on MySQL for data but I don't want every one of the client machines (20 in total) connecting to the database directly because it leaves too much exposed on the server side.

What method is used in large corporations where multiple client machines running some program which uses data stored in MySQL. Surely they do not all connect to the database directly??

BTW - Lets keep this confined to Java please

user
  • 158
  • 6
  • 19

2 Answers2

2

Often the solution is to have a single web-app that all the Java clients connect to, and it is that web-app that talks to the database. You would give the web-app the credentials and permissions it needs to perform the DB operations you want.

Often, you also have the Clients identify themselves through some means (password authentication is common). And then the web-app keeps an audit log (either in DB or in a file) in order to keep track of who did what, in case of problems that arise.

Daniel
  • 4,481
  • 14
  • 34
  • Okay, that sound good, A small app on the server that the client can connect to via a SSL connection, get the data and close the connection. No database passwords store on the client so I am happy! – user Jun 23 '15 at 17:29
0

You can handle it with Spring BasicDataSource, look at more voted answer for this question and here is another example

Also take a look at MySQL connection pooling doc

If you want every machine connect to same java-handled pool I would create two applications, one that access data through datasource with connection pooling and exposes web/rest services. Second application could consume those services from 20 or more machines.

Community
  • 1
  • 1
wdonet
  • 373
  • 3
  • 9