Meaningless Drivel is fun!*
The moose likes JDBC and the fly likes Retriving time from Oracle database in JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Retriving time from Oracle database in JSP" Watch "Retriving time from Oracle database in JSP" New topic
Author

Retriving time from Oracle database in JSP

Ummu Hanisah
Greenhorn

Joined: Aug 26, 2013
Posts: 10

Hi, I need to display certain column from Oracle database. But the columns for stime, etime and reservedate doesn't display in my jsp page.
I use data type timestamp in those three columns.

My program throw an exception "Exception is ;java.sql.SQLException: Invalid column name"



My servlet code snippet.




Here is my jsp code

K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 2564
    
    9

Welcome.

Your error is "invalid column name". Have you tried the run the query directly in Oracle? Does the table have those column names?

I'm not aware that Oracle can just store time. Usually the type is date with timestamp.

check out this if you are using Oracle 11g. The extract() function may be your answer.


K. Tsang JavaRanch SCJP5 SCJD/OCM-JD OCPJP7 OCPWCD5 OCPBCD5
Ummu Hanisah
Greenhorn

Joined: Aug 26, 2013
Posts: 10

K. Tsang wrote:Welcome.

Your error is "invalid column name". Have you tried the run the query directly in Oracle? Does the table have those column names?

I'm not aware that Oracle can just store time. Usually the type is date with timestamp.

I've already run the query in Oracle and it did display the data on those column.
Yup, Oracle store both date and timestamp and it can also show only the time.

K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 2564
    
    9

Right. Then you need to assign a (column) name to those to_char() columns. Because java doesn't know.

select ..., to_char(stime, 'HH24:MI:SS') stime, to_char(etime, 'HH24:MI:SS') etime from ...
Ummu Hanisah
Greenhorn

Joined: Aug 26, 2013
Posts: 10

Thanks a lot!

At first I encounter exception "Session Time Zone not set!".
Now it works fine. Finally I can move to my next module.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Retriving time from Oracle database in JSP