File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes getting date from oracle table Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "getting date from oracle table" Watch "getting date from oracle table" New topic

getting date from oracle table

Aravind Prasad
Ranch Hand

Joined: Dec 28, 2005
Posts: 265
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="";
{ if(rs.getDate(1)==null)

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
{ sail_date = rs.getDate(1);
it is showing the date from the table..

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

Thanks in advance..
stu derby
Ranch Hand

Joined: Dec 15, 2005
Posts: 333
If you read the JavaDocs for ResultSet, here:
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:
I agree. Here's the link:
subject: getting date from oracle table
It's not a secret anymore!