Home > Blockchain >  Client-Server Java Application linked to MySQL database
Client-Server Java Application linked to MySQL database

Time:12-02

I am trying to make a Java application in a client/server way. The client is a GUI which displays data from the server. The server is connected to a MySQL database.

It's probably a classic question, but I have no idea where to start! How do I link the GUI to the server? How do I manipulate the data from the server? It's an app with several features that I have to implement, all about the data in my database.

Can anyone please give me a route to start or show me steps or some tutorials?

Thank you in advance.

CodePudding user response:

Connecting to DB: look into JDBC it's a Java's database connection api ,with it you can connect to db and execute all the database operations.

As for as connecting UI, if you are devoloping a web ui then you can use JSP

If you want to develop bit more advanced application then look into Spring project.

CodePudding user response:

If you use a spring-boot application you could add specific dependencies in order to have a connection to a client using REST MVC module. Read more: https://www.redhat.com/en/topics/api/what-is-a-rest-api

Required dependencies

MySQL Driver Spring Data Jpa (which uses hibernate as an Implementation and maps your entities to db tables) Spring Web (which uses the MVC concept)

https://start.spring.io/ - to generate a maven spring boot project. you can choose the dependencies on the right tab.

once you have all dependencies you should create an app.properties file to manage your properties such as:

database, user, password, hibernate properties, etc.

create repositories for crud operations. There are many tutorials you can find online.

so far you have a back-end with mapping to a db.

as for front-end you have many technologies you can use. but for this example we will look at react. ( library for building user interfaces ) basically this is the GUI part. react as of now is the most popular one. You can read here about react - https://reactjs.org/.

once you create a client-side app you can make via your IDEA (e.g of an IDEA for react is Visual studio code) calls to back-end to fetch data from DB.

this is called a full-stack software.

TL;DR

  1. You need a back-end program (Spring boot) with required dependencies
  2. A driver for DB (in this case MySQL) which will be mapped by hibernate.
  3. A Front-end client (in this case REACT) in order to make calls.

ofcourse this is just a small example of how a complete app should be build but you should read more about client-side technologies and choose what suits you.

  • Related