Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Date format and SQL Server stored procedure

 
Jayashree Varahan
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm calling a SQL Server stored procedure using the following statement. This procedure returns an output parameter which is of type DateTime.
CallableStatement statement = databaseConnection. prepareCall("{call test(?)}");
statement.registerOutParameter(1, java.sql.Types.DATE);
I'm getting
java.sql.SQLException: [Microsoft][ODBC SQL Server Driver] Optional feature not implemented

 
Peter Tran
Bartender
Posts: 783
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jayashree,
You're just lucky I ran into this problem before. The exception returned from the driver isn't very clear what it means "Optional feature not implemented."
The problem is SQL Server doesn't not support java.sql.Types.DATE. You'll have to use java.sql.Types.TIMESTAMP.
It took me a long time to figure this out. JDBC doesn't standardize the exception message. For awhile I thought it was a bug in the driver implementation. I even sent a bug report to the company who wrote the driver. They told me the error message meant and what to do. Unfortunately for us, if you move to ORACLE you may have to modify your code back to java.sql.Types.DATE. So much for being platform independent...
Cheers,
-Peter
 
Jayashree Varahan
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much!!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic