• 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

getting date from oracle table

 
Ranch Hand
Posts: 265
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Ranchers..
I'm using JSP and Oracle for doing a project
the table details for the particular table is like this

sailing_date date nulls

so in the resultset when i try to get the values in dd/mmm/yyyy format it is showing no values..

the code i've done like this
-------------------------------------------------------------------------

Calendar timeNow = Calendar.getInstance();
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MMM/yyyy");
Resultset rs = stmt.executeQuery(query);
String sail_date="";
while(rs.next())
{ if(rs.getDate(1)==null)
sail_date="";
else
dateFormat.format(rs.getDate(1));
}
out.println(sail_date);

--------------------------------------------------------------------------
if there is no date value in the table then it is displaying fine..
if there is date values .. it is showing error..
the error is

java.sql.SQLException: No data found

But there is a date value in the table..
if i remove all the formating and put just
while(rs.next())
{ sail_date = rs.getDate(1);
}
out.println(sail_date);
it is showing the date from the table..

What may be the problem.. ranchers
Please help me..

Thanks in advance..
regards
Aravind
 
Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you read the JavaDocs for ResultSet, here:
http://java.sun.com/j2se/1.5.0/docs/api/java/sql/ResultSet.html
you will see that they say:
For maximum portability, result set columns within each row should be read in left-to-right order, and each column should be read only once.

I don't know that that's your problem, but try this:
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic