strange_098
strange_098

Reputation: 1391

How save all actions from users in MySQL Database - Java Application

I made a java application and to access it you must login.

There are 2 types of login: admin and normal user. I want to save information about all the movements of normal users. In other words I need to know which user added, changed or deleted anything from the database.

Is there any way to do this?

I know I'll have to create a new table in the database, but do not know anything else. Does anyone can help me clarify this doubt I have.

I honestly don't even know where to start.

I apologize if I did not make myself clear.

Thank all any help you can give me.

Greetings.

Any questions I will try to explain as best as possible.

Upvotes: 2

Views: 2345

Answers (2)

Raging Bull
Raging Bull

Reputation: 18767

You need to create a table like:

User   |  FormName  |  Action   |  ActionTime

And insert data into this table whenever an action is performed by the user.

For example:

When a product is added by the user. Insert that detail into this table. Something like:

UserID   |  FormName  |  Action                |  ActionTime
1           Inventory    User added a product     2014-4-4 12:10:00

You will have to do whenever user add,edit,delete anything. So I would suggest a static function for that.

EDIT:

Now you can track a user by:

SELECT * 
FROM UserActionTable 
WHERE UserID=1

Upvotes: 3

subhash lamba
subhash lamba

Reputation: 216

Create trigger on database for insert,update and delete rows from database table. and when any operation perform on those table than trigger will be fire by database automatically at that time add row(data) in history table.

https://dev.mysql.com/doc/refman/5.0/en/create-trigger.html

using above link you can perform this task easily.

Upvotes: 0

Related Questions