my dog learned polymorphism*
The moose likes JDBC and the fly likes How to set date in mysql using prepared statement? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "How to set date in mysql using prepared statement?" Watch "How to set date in mysql using prepared statement?" New topic
Author

How to set date in mysql using prepared statement?

Balaji Ragupathy
Greenhorn

Joined: Oct 01, 2011
Posts: 2
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

Joined: Jan 10, 2002
Posts: 60817
    
  65

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Balaji Ragupathy
Greenhorn

Joined: Oct 01, 2011
Posts: 2
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.
 
Consider Paul's rocket mass heater.
 
subject: How to set date in mysql using prepared statement?
 
Similar Threads
Servlet API 2.2
NumberFormatException : null
Problem in using date in WHERE clause in SELECT query in Servlet.
input to ireport
about hidden from fields