can someone please help me.my problem is i have no column on the user interface and when i submitt this form the Date is autometically insert into database this Date must be server Date not the client Date bcz client Date may be wrong but server date always right please give an example of code in JAVA that would some how solve my problem.
U can do the same. Are u calling a servlet/jsp when the form is submitted in both cases u could call Calendar.getInstance().getTime() which gives u the server date and the same can be used in the insert statement of ur table
Satish SN<br />SCJP 1.4 & SCWCD 1.4
posted 15 years ago
Thanks but can u give some example of code about that.
since poster of this thread is using sql server,which already has Datetime datatype for dates and can be used as setTimeStamp() of PreparedStatement or sql server has GETDATE()function to get date in sql
Gravitation cannot be held responsible for people falling in love ~ Albert Einstein
I'd use GETDATE() in the sql, or in oracle SYSDATE (I think mysql uses 'now()')
I wouldn't use a db trigger to insert the date, here's why.
With our current prod db we did use a trigger to update the date to now on insert.
However, we've also had to do a lot of data insertion of old data, and to insert this data and keep the original dates in the old data, you have to turn off the trigger before running the import/insert.
This means a production downtime (because turning off the trigger during normal operation would be bad of course).
In hindsight, we would have stuck with a 'not null' constraint on the date time column and gone with 'sysdate' or the like in the sql.
Who among you feels worthy enough to be my best friend? Test 1 is to read this tiny ad: