• 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

setDate in Callable Stmt

 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Please let me know what is wrong with the piece of code below:-
SimpleDateFormat df = new SimpleDateFormat("M/d/yyyy");
Calendar cal = Calendar.getInstance();
java.util.Date date = df.parse("05/10/2005");
cal.setTime(date);
System.out.println("cal: " +cal.getTime());
CallableStatement cs = con.prepareCall("{ CALL dbo.spData(?,?) }");
cs.setDate(1,new java.sql.Date(cal.getTime().getTime()));

I get the following exception...

java.sql.SQLException: [Microsoft][ODBC SQL Server Driver]Optional feature not implemented
at sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.SQLBindInParameterDate(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcPreparedStatement.setDate(Unknown Source)
at TestChannelData.main(TestChannelData.java:32)
 
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
anytime you access a dB you need to do try{} then catch{} after it. so like:

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