aspose file tools*
The moose likes JDBC and the fly likes Need to update date from jsp to mysql database. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Need to update date from jsp to mysql database." Watch "Need to update date from jsp to mysql database." New topic
Author

Need to update date from jsp to mysql database.

Jaidev Arer
Ranch Hand

Joined: Mar 12, 2010
Posts: 38
Need help to write a update query to update current (sysdate) from JSP to mysql database.
The problem is mysql will store data field in yyyy-mm-dd format.
So how to go about it.
Thganks
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42648
    
  65
The problem is mysql will store data field in yyyy-mm-dd format.

What is the problem with that? Besides, if the DB field is of type timestamp or some such, then it has no format associated with it - any formatting would need to be done by the client.


Ping & DNS - my free Android networking tools app
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30972
    
159

Jaidev,
It is good practice to use a PreparedStatement. Then you can call setDate() and getDate() rather than worrying about database specific formatting. And use SimpleDateFormat to display in the desired format in your JSP.

It is also good practice to do your JDBC code from someplace other than a JSP.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Jaidev Arer
Ranch Hand

Joined: Mar 12, 2010
Posts: 38
Jeanne Boyarsky,
Thanks for your time.
Will work on that line.
Thanks again
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Need to update date from jsp to mysql database.