• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Need to update date from jsp to mysql database.

 
Jaidev Arer
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34396
346
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Jaidev Arer
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeanne Boyarsky,
Thanks for your time.
Will work on that line.
Thanks again
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic