J
J
Javist20212021-08-04 16:35:26
Java
Javist2021, 2021-08-04 16:35:26

Saving user actions in java program?

Hello. I'll start with a banality in java newbie)). I started working on one project, the essence of which is to store user data received from a text field (JTextField) in a table (JTable). There are three fields, a table and an "Add" button, the user fills in the fields and presses the button, the data is instantly displayed in the table and saved to a file. But of course, if you close the program and run it again, all received data disappears. And well, Java gurus direct me to useful resources, I have already rummaged through the entire Internet!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
O
Orkhan, 2021-08-04
@Javist2021

Good afternoon!
1) Let's start with the fact that you need to select the database in which you will store the data. For example sqlite.
https://www.sqlite.org/index.html
2) You need a driver to work with the database of your choice. In java - jdbc.
https://github.com/xerial/sqlite-jdbc
For convenience, you can master ORM technology and study hibernate or mybatis, etc. You can take at least - ormlite.
3) Next, you get the information entered by the user, if necessary, validate it and write it to the database.
4) At the next start of the application, the data in the JTable is filled from the database.
https://www.youtube.com/watch?v=jpGn8rd_3Sc

J
Jacen11, 2021-08-04
@Jacen11

Java has nothing to do with it, so it works in all languages, you need to save the data to a file or to the database
even did not play games on your computer? there you can see that everything is saved to the file

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question