• 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

smalldatetime format error

 
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Probably quite a simple problem but...

I have a simple form where a user inputs some data (including a date), I want the user to eneter the date in dd/mm/yyyy format (e.g. 21/02/2005), my SQL database is using 'smalldatetime' format, which as i see stores the date in dd/mm/yyy format. So, there shouldn;t be a problem should there? So why is it, when I insert a new record i get a:

"java.sql.SQLException: The conversion of char data type to smalldatetime data type resulted in an out-of-range smalldatetime value." error? Is it because I don;t have any time values on the end of the date (e.g. 21/02/2005 00:00:00.00 or summin')?

Cheers

K.
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
post the code
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I strongly recommend using a prepared statement here. You can parse the date in Java and then pass the date object into a stored procedure. This allows the driver to deal with conversion details.
 
Ranch Hand
Posts: 1143
1
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
K,
Does "mySQL" support SQL Escape Syntax?

Good Luck,
Avi.
 
Kevin P Smith
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's OK I changed it from smalldatetime to just datatime, that seems to have fixed it for some reason.
 
Come have lunch with me Arthur. Adventure will follow. This tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic