File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC 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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "getting date from oracle table" Watch "getting date from oracle table" New topic
Author

getting date from oracle table

Aravind Prasad
Ranch Hand

Joined: Dec 28, 2005
Posts: 263
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
stu derby
Ranch Hand

Joined: Dec 15, 2005
Posts: 333
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:
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: getting date from oracle table
 
Similar Threads
why what i search is not what i want?
gettind date from the oracle table!
Showing Date if no value
How to get all request stored in databse between two date
A challenge while formatting date value from the database