Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to set date in mysql using prepared statement?

 
Balaji Ragupathy
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When we select the date from the drop down box or writing in text box it needs to store in the date format in mysql database. getting the date input from the user not the current system date or time. please help me out with the code.
I tried the following design page:-

tried with two types of solution one is

and another one was


for both, the result was when I give the input text field 07-06-1988 it is storing the value in database as 0000-00-00 otherwise giving null in the browser. sometimes storing the value as 1970-01-01.
The datatype which I used for date in mysql is data datatype.
I tried even parsing for the string value to convert into date format it didn't worked. Nothing worked out for me.
Please help me out with it... someone please give me the solution for this.

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64822
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moved to the JDBC forum as this has nothing to do with JSP.

Your first step, before you do anything else, is to remove this code from the JSP and put it into a Java class. JSPs should have no Java code in them -- and especially no database access code!

You might find this article helpful.
 
Balaji Ragupathy
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Mr.Bear for your reply and your suggestions. I try to do it.Anyway I might be wrong in the programming but please someone help me out to store date in mysql DATABASE using data type date.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic