File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
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: 61766
    
  67

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to set date in mysql using prepared statement?