aspose file tools
The moose likes Servlets and the fly likes Updating timestamp field Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Servlets
Reply Bookmark "Updating timestamp field " Watch "Updating timestamp field " New topic
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..
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Updating timestamp field
 
Similar Threads
how to check whether a string is null or not
converting the date/time fields into Strings
Parsing date/time field
making user enter the parameter of field in doGET
More .js Calendar Problems