File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Spring and the fly likes Getting an error while fetching Date time from DB in Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Getting an error while fetching Date time from DB in Java" Watch "Getting an error while fetching Date time from DB in Java" New topic
Author

Getting an error while fetching Date time from DB in Java

Gershwin Yesudhas
Greenhorn

Joined: May 09, 2010
Posts: 21
Hi Ranchers,

I'm trying to fetch a column from DB in my java code but getting the below error.

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.Exception
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:583)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:501)
javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

root cause

java.lang.Exception
com.avon.gi.repsuite.ctrl.OnlineOrderDetailsController.handleRequest(OnlineOrderDetailsController.java:552)
org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:809)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:501)
javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)



The column name is ORD_MGMT_IP_DT and it is of Date format for example in my case it is 3/12/2010 9:27:11 PM in the db.
I need to fetch the date time and the AM/PM in the format dd/MM/yyyy hh:mm:ss a
I tried fetching it by writing it as to_char(rep_ord_trkg.ord_mgmt_ip_dt,'dd/MM/yyyy hh:mm:ss a') AS OrderDate in Java.


But am not getting the values on the page instead, I'm getting an Error 500 on page. When i tried without the 'a' i.e for the AM/PM i got the value in the page but the time was incorrect, like 12/3/2010 9:03:11. I'm quite confused that, how this is failing to fetch me the correct values when given with 'a' and it is throwing exceptions when given with 'a'.

Kindly help me out on this ranchers. Thanks a ton in advance.Awaiting your replies.


Best Regards,
Gersh
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Which database are you using ?


[My Blog]
All roads lead to JavaRanch
Gershwin Yesudhas
Greenhorn

Joined: May 09, 2010
Posts: 21
I'm using Oracle 10G.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Your format is not correct. Try 'DD/MM/YYYY HH:MI:SS PM' instead.
Gershwin Yesudhas
Greenhorn

Joined: May 09, 2010
Posts: 21
Thanks a lot Christophe. It worked. Thanks again Rancher.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Getting an error while fetching Date time from DB in Java