Help coderanch get a
new server
by contributing to the fundraiser
  • 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

Class java.sql.Date

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
CAN ANYONE HELP OUT WITH THIS ???
java.text.SimpleDateFormat formatter = new java.text.SimpleDateFormat("mmm dd yyyy hh:mm a");
java.util.Date dt = new java.util.Date();
String dtStr = formatter.format(dt);
java.sql.Date objDt = new java.sql.Date.valueOf(dtStr);
cStmt.setDate(2,objDt); (cStmt is an object of Callable Statement)
THE ABOVE CODE WHEN COMPILED GIVES THE FOLLOWING COMPILER ERROR(FYI I AM USING JDK1.2.2)
Class java.sql.Date. valueOf not found. java.sql.Date objDt = new java.sql.Date.valueOf(dtStr);
^
1 error
 
author
Posts: 154
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


The above code is trying to instantiate a class called "valueOf" in the java.sql.Date package. You're missing some brackets! This is what you need:

Out of interest, if all you're trying to do is set the parameter in the callable statement to the current date/time, you could simplify it down to one line:

David
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
valueOf method in java.sql.Date is not an instance method. It is a static method.
java.sql.Date objDt = new java.sql.Date.valueOf(dtStr);
replace the line with the line dispalyed below and it should be fine
java.sql.Date.valueOf(dtStr);
Chidda
 
reply
    Bookmark Topic Watch Topic
  • New Topic