• 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

Collision of Date format between java.sql and SQL Server

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have a doubt about setting date format for database field when I use java.sql.Date format in my java applications.There is a collision between SQL Server's "month/day/year' format and java.sql.Date class' "year/month/day" format.If I tried to store "year/month/day" format in SQL Server table I got the error "Microsoft ODBC SQLException, Optional feature not implemented". How can I store that kind of date in SQL Server? Can I create american date format in java?How?

Yours faithfully,
Ramesh RK
 
Bartender
Posts: 2661
19
Netbeans IDE C++ Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This should not happen.

Can you please post your java code part, including insert/update statement, and the code where you set the date?

Regards, Jan
 
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
See the code accidentally created as a new post.
 
Jeanne Boyarsky
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
You are using
ps.setDate(5,dtF5);
which should be taking care of the date setting for you.

There isn't a different format for java.sql.Date in Java. It just represents a number of milliseconds. If you output the date value before setting it in the prepared statement, is it correct?
 
Jan Cumps
Bartender
Posts: 2661
19
Netbeans IDE C++ Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I see (in the code thread) that your table column is defined as DateTime.

Try using setTimestamp() to set the value for the field.

This solved this person's similar problem.

Regards, Jan
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic