• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

problem while insert date data in mysql

 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am facing folowing problem while inserting data into mysql table
mysql table is
Create table MyDate(Date Date, MyDate DateTime)

These record I have added manuly.
When I try to add record through Java it put 00 into all fields. Here is java code

=====================
Now result is
C:\Padmashree\working>java MyTime
2002-40-04 18:40:37
Thu Apr 04 18:40:37 CST 2002


What is happening here?
Do i need to convert Java date type to mySql Date type ? is then how?
Any help greately appreciated.
-
padma
[ Edited by Dave to format code ]
[ April 04, 2002: Message edited by: David O'Meara ]
 
Ranch Hand
Posts: 265
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
why don`t u insert directly current date in ur datatbase like "insert into mysql values(getdate())"
then u get tge out putlike date format ..
try this one if not understabdf mail me
 
Graham Thorpe
Ranch Hand
Posts: 265
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sorry just now i said to sqlserver...
just put curdate()...
inserrt into mysql values(curdate(),curdate())
 
padma patil
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have to insert date and time data into mysql database through java prpgram.curDate() method works for mqsql but not in java program.
Realy appreciate if anyone solve this problem.
-
padma
 
Ranch Hand
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Use prepared statements to deal with inserting/updating dates. This way you can separate the formatting from the SQL update.
Changed code:

Jamie
 
padma patil
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Thanks.
Now My program works with PreparedStatement.
-
padma
 
reply
    Bookmark Topic Watch Topic
  • New Topic