File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes java.sql.SQLException: [Microsoft][ODBC SQL Server Driver]Opti onal fature not implem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "java.sql.SQLException: [Microsoft][ODBC SQL Server Driver]Opti onal fature not implem" Watch "java.sql.SQLException: [Microsoft][ODBC SQL Server Driver]Opti onal fature not implem" New topic
Author

java.sql.SQLException: [Microsoft][ODBC SQL Server Driver]Opti onal fature not implem

susanth puthanveedu
Greenhorn

Joined: Apr 03, 2006
Posts: 6
in my project i wanted insert a date object to the database for that i am using PreparedStatement.setDate(fieldNum,dateObject), i tried out the code segmets and used the java.sql.date onject only but i am gettig the exception"java.sql.SQLException: [Microsoft][ODBC SQL Server Driver]Optional feature not implemented".see the code below which i used
String sql = "insert into debug (filing_date) values (?)";

PreparedStatement insertPS = dbConn.prepareStatement(sql);

String dateS = "2001-00-01"; //That's jan 1, 2001

java.sql.Date date = java.sql.Date.valueOf(dateS);

insertPS.setDate(1,date);



insertPS.executeUpdate();
@@@@@@@@@@@@ i tried using this way also to get into the real format "MMM d, yyy"but got the exceptoin this time also, the code is

MMM d, yyy format, which java.sql.Date doesn't accept: String dateIn = "January 1, 2001"; String formatIn = "MMM d, yyyy"; // format of incoming string

//parse the date using java.util.Date classes

ParsePosition pp = new ParsePosition(0);

SimpleDateFormat sdfi = new SimpleDateFormat(formatIn);

java.util.Date date = sdfi.parse(dateIn,pp);

if( date == null ) (throw new RuntimeException"Unparsable date: "+dateIn);

//convert a java.util.Date to a java.sql.Date

java.sql.Date sqlFromLong = new java.sql.Date(date.getTime());

//output is: 2001-01-01 System.out.println("sqlFromLong (java.sql.Date): "+sqlFromLong);

pls help me regardig this thanks in advance susanth
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Don't use the JDBC-ODBC bridge. Use a proper type 4 driver like jTDS or the one you can download from microsoft.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Mr. C Lamont Gilbert
Ranch Hand

Joined: Oct 05, 2001
Posts: 1170

what database are you using?
susanth puthanveedu
Greenhorn

Joined: Apr 03, 2006
Posts: 6
Tank you Mr. C Lamont Gilbert for respondig to my query.here i am using the SQL database.
regards
susanth
Shailesh Chandra
Ranch Hand

Joined: Aug 13, 2004
Posts: 1081

susanth,

You have ignored Paul's response, It might be problem with ODBC driver as it states some features are not implemeneted.

Shailesh


Gravitation cannot be held responsible for people falling in love ~ Albert Einstein
susanth puthanveedu
Greenhorn

Joined: Apr 03, 2006
Posts: 6
No shailesh i respect those who listen to my problems.for Mr. C Lamont Gilbert i can give a one word answer and for Pauls response i need to work on it.

Thank you Mr.Paul Sturrock your advice really helped me in my project. i tried using jTDS and it is working properly without giving any execptions.
Thanks a lot
regards
susanth
Shailesh Chandra
Ranch Hand

Joined: Aug 13, 2004
Posts: 1081

Originally posted by susanth puthanveedu:
No shailesh i respect those who listen to my problems.


I also didn't mean that !!

I just wanted you to consider that option too, if you din't notice that post.


Shailesh
Mr. C Lamont Gilbert
Ranch Hand

Joined: Oct 05, 2001
Posts: 1170

Originally posted by susanth puthanveedu:
Tank you Mr. C Lamont Gilbert for respondig to my query.here i am using the SQL database.
regards
susanth


Heh, they are all "SQL" databases. Wondering if you are using "Jet" or MS "SQL Server" or whatever its called.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java.sql.SQLException: [Microsoft][ODBC SQL Server Driver]Opti onal fature not implem