File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Collision of Date format between java.sql and SQL Server

 
rameshmca rk
Greenhorn
Posts: 17
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Jan Cumps
Bartender
Posts: 2575
11
C++ Linux Netbeans IDE
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 33671
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See the code accidentally created as a new post.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 33671
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • 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: 2575
11
C++ Linux Netbeans IDE
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic