This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC and the fly likes date problem not in access but sql server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "date problem not in access but sql server" Watch "date problem not in access but sql server" New topic
Author

date problem not in access but sql server

kajal sharma
Greenhorn

Joined: Oct 04, 2000
Posts: 22
Dear java guru's

When I try to insert records in Access97 ---> no problem
but when I enter records in MS sql server then I got the following runtime exception
java.sql.SQLException: [Microsoft][ODBC SQL Server Driver]Optional feature not implemented
---------------------------------mycode---------------------------------------

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
java.util.Date xdate=sdf.parse(a2);
//java.sql.Date date=java.sql.Date.valueOf(a2);//I even try this but same exception
//System.out.println(date);
System.out.println(new java.sql.Date(xdate.getTime()));//2000-12-09
PreparedStatement updater = myConnection.prepareStatement("update FormA set age= ? ,"+
" cough= ? "
+ " where sitesrno= ? ");
updater.setInt(1,Integer.parseInt(a4));
updater.setString(2,a7);

updater.setDate(3,new java.sql.Date(xdate.getTime()));
updater.setInt(4,Integer.parseInt(s));

int updateCount = updater.executeUpdate();
updater.clearParameters();

any suggestions
kajal
kajal sharma
Greenhorn

Joined: Oct 04, 2000
Posts: 22
Dear java guru,

when I tried timestamp as this
{ts '1999-11-11 00:00:00.000000000'}
I got the following run time exception
java.lang.IllegalArgumentException: Timestamp format must be yyyy-mm-dd hh:mm:ss.fffffffff
If i use time stamp as
1999-11-11 00:00:00.000000000
now exception is
java.sql.SQLException: [Microsoft][ODBC Driver Manager] Invalid argument value
I am setting time stamp as
String ydate=a2+" 00:00:00.000000000";
updater.setTimestamp(3,Timestamp.valueOf(ydate));
What is the right ways to use timestamp
kajal
[This message has been edited by kajal sharma (edited March 20, 2001).]
[This message has been edited by kajal sharma (edited March 20, 2001).]
 
 
subject: date problem not in access but sql server
 
Similar Threads
Problem in getting date from JSP Form
Between Syntax
java.sql.SQLException: [Microsoft][ODBC SQL Server Driver]Opti onal fature not implem
weird java dates!!!!
setDate in Callable Stmt