Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Retriving time from Oracle database in JSP

 
Ummu Hanisah
Greenhorn
Posts: 10
Eclipse IDE Oracle Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3610
16
Firefox Browser Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ummu Hanisah
Greenhorn
Posts: 10
Eclipse IDE Oracle Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3610
16
Firefox Browser Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10
Eclipse IDE Oracle Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!