java/mysql how to get changed data - java

I'm working on a Java program that is connected to a MySQL database. One of the things that I want to do is show if/what data change to a current table has been made. Any ideas?

Related

Does Firebase Database store the latest data or all the data with timestamp?

I have enabled the Firebase Persistance in my application. If I am setting a value to a child such as
child.setValue("XYZ");
I am not adding value to the parent tree. I am just updating the value of one child. So here, the value will be updated again and again by the user as he uses the application like many times a day. So, my question is, if user do not have inter-net connection for days, will this thing generate bug as Firebase is storing these things in cache. Does all the data get stored offline with mechanism something like commits in git or just the latest value is stored. I am asking this thing because it's kind of cache so if firebase stores data with all the logs and values the child gets then it can make my application buggy and slow as it will carry all the cache all the time.
If you are getting offline and you are updating a single record than, when your getting back online, only your last update will be updated on the server. Let's take an example. You have a product in which you store a timestamp. Every time you make an update, you change that timestamp with the current timestamp. If you are offline and you edit that product several times, when you'll be back online, only the last timpstamp will be added on the server.
But remember, this not happening when you add new data. When you do this, all the new data is added on the server accordingly to time you have added. This happening also when you delete.
Hope it helps.

Use SQL without implementing a new SQL table in the program

There is a lot of tutorials out there showing me how to create a new table and ammend the data. But will creating a new table every time overwrite my existing table?
Once the table has been created and the rows of data have been added, I wouldn't need my program to create a new table again. Just read and ammend from it.
I don't want the user to create a table, so I just want the table to already be there before I even run my program.
I figured I could use run something like this to create my database tables once:
https://www.tutorialspoint.com/jdbc/jdbc-create-database.htm
Run it! And then once it is created, use this next guide to connect to where I stored it in the actual program.
https://www.tutorialspoint.com/jdbc/jdbc-select-database.htm
Be nice to find a tutorial on how to just manually make the database parameters outside of code.
The project is for university, they want me to create a client similar to MySpace. Have clients connect to a server, share music and message friends. I have done the UI and multi threaded server connections and understand how to read and write data to the UI or File. Just figured an SQL database would be the best way to store all this user data.
You just need to check the table Exist or not.
If the table exist then use it else create it and then you can use it.

Refreshing JavaFX scene from updated SQL database?

I am currently writing a program which retrieves data from a SQL database and uses the data to populate a pie-chart on a JavaFX scene. So far, this has been a success.
What I am wondering is if it is possible to repopulate and refresh the pie chart as new data is entered into the database. So far the only solution I have found is to close the program and reopen it, which is not really much of a solution.
I can provide my code if needed.
Grateful for any tips you can give, thanks!
What I am wondering is if it is possible to repopulate and refresh the pie chart as new data is entered into the database.
The beauty of graphs/Charts in FX is that they are all dynamic, and change.
if you add new data to your dataCollection, or set your entire database to PieChart.setData(data);
You would have to set up a listener to listen in on your DB and changes, or listen to the changes on whatever is changing your DB. Is it external or internal to your Application?
If it's Internal than you can set up the listener with a flag and do it then, if it's External then you will either
have to poll the database x seconds/minutes
somehow set up SQL code to update something in your application and
set up a listener there (such as How to implement a db listener in Java)

How should I refresh gui that is displaying data from a mySQL database?

I am using JDBC to connect to a mySQL database in my program. During runtime, the user can modify the contents of the database by adding new ones (more functionality is coming but right now that's all I have). However, when a new entry into the database is created I want the gui that is displaying the content to update themselves with the modified data.
I know how to update the gui elements, but that doesn't seem to apply to the ResultSet created from my database.
I am quite new to mySQL and JDBC so any help would be very appreciated !
First questions:
- If it is a web application, you can use Ajax and ajax callback to manage return of your application (success or failure)
- If it is a standard application, you can manage in that way (which work from my side):
As soon as user added data, you needs to wait the result of your database. If (insert/update/delete) does not return any exception, you have to modify your GUI (add/update/remove) your display. If you have any issue you should not modify your gui.
Do not perform any select all, as you can crash your application in case of huge db.

How to retrieve data from a table in a database and print it in a table in a GUI form in Java

I have a database with tables in it which contains information. I would like to retrieve data from the table which is on the database to the table which I have made on a GUI form. I have tried retrieving the data using system.out.print method and I get results, meaning the database connection works and recognizes the table. Only problem is I do not know how to that for tables in the code. Please keep in mind that the GUI I made, the code was generated automatically so I do not have 100% access to the code.
Your connection to the database seems to be correct, however, you cannot set your table to contain the values you need. If the diagnosis is correct, then below you will find useful information:
I do not know what are you using for tables, I will assume you are using JTable, but if you use something else, only technical details should change as the thought process should remain intact.
To get general knowledge, please read this tutorial.

Categories