| Author |
Updating timestamp field
|
sam davis
Greenhorn
Joined: Jun 16, 2003
Posts: 18
|
|
Hello, Im creating a reporting servlet which shows the values of the row for a certain username and then lets user make changes to it and updates it. If a user sets the timestamp field to blank in the form and hits 'update' button, it updates it to some random date and time instead of showing it blank. This is wut my code looks like in dopost()just to show blank if the users sets it to blank. String m = req.getParameter("initialized"); if (m == null || m.equals("")) member.initialized = null; member.update(); in my Member class, i have this code in the update method: String m =""; if(initialized == null) m = null; update = "UPDATE vippas SET initialized = \"" + m + "\"";. Im totally stuck here..Could any1 please tell me wut the problem is and suggest a solution. Thanks for your help.
|
 |
Mike Curwen
Ranch Hand
Joined: Feb 20, 2001
Posts: 3695
|
|
You SQL will translate to : UPDATE vippas SET initialized = "null"; That probably won't make sense to a column of type DATETIME or TIMESTAMP.
|
 |
sam davis
Greenhorn
Joined: Jun 16, 2003
Posts: 18
|
|
|
So, what should i do???..cos i have run out of solutions???.
|
 |
Mike Curwen
Ranch Hand
Joined: Feb 20, 2001
Posts: 3695
|
|
What i was trying to point out was that you are quoting the java null value with double quotes. So when it gets to the database, this is no longer SQL NULL, it is a string with the letters 'n', 'u', 'l' and 'l'.
|
 |
sam davis
Greenhorn
Joined: Jun 16, 2003
Posts: 18
|
|
Hey Mike, I understood wut u meant and solved it..I'm sorry i couldn't post a reply earlier and you had to reply again. Thanks for your help...appreciate it..
|
 |
 |
|
|
subject: Updating timestamp field
|
|
|