This week's book giveaway is in the Spring forum.
We're giving away four copies of Spring in Action (5th edition) and have Craig Walls on-line!
See this thread for details.
Win a copy of Spring in Action (5th edition) this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

problem in inserting time values in jsp  RSS feed

 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here we have written insert query , it should insert with time, Date is inserting well but the problem with time ..Here is my code please help me out from this..

 
Rancher
Posts: 1915
15
Android Eclipse IDE Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HH:mi  should it be HH:mm?
 
sushma swaraj
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply ...

i have changed format while inserting it going date value properly but not going time stamp going like 12.00.00
 
sushma swaraj
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
   HH:mm  ---  i have using this one but its showing Error as ..Error 500: java.sql.SQLDataException: ORA-01810: format code appears twice
 
Swastik Dey
Rancher
Posts: 1915
15
Android Eclipse IDE Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What database are you using?  and try this once YYYY-MM-DD HH:mm:ss
 
sushma swaraj
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oracle...YYYY-MM-DD HH:mm:ss ..this also showing Error..Please help me
 
sushma swaraj
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
its going time every time like this.. 2017-03-22 AM 12:00:00

it was not another timing
 
Swastik Dey
Rancher
Posts: 1915
15
Android Eclipse IDE Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry in oracle mi indicates time.  Try this YYYY-MM-DD HH:mi:ss

I found some details here

https://docs.oracle.com/cd/B28359_01/server.111/b28286/sql_elements004.htm#SQLRF00210

Look for  the date fomats.
 
sushma swaraj
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Here i have uploading one document So i have chosen file item Here Please check my code
 
Swastik Dey
Rancher
Posts: 1915
15
Android Eclipse IDE Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What's the issue, just date?
 
sushma swaraj
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes Just date is inserting but i want to insert with time
 
Swastik Dey
Rancher
Posts: 1915
15
Android Eclipse IDE Java Java ME
 
Swastik Dey
Rancher
Posts: 1915
15
Android Eclipse IDE Java Java ME
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What appears is you have to convert the date to sql time stamp and then use to_timestamp method instead of to_date method to store the date with timestamp.  Another point is if you use PreparedStatement instead of Statement it will be better.
 
Swastik Dey
Rancher
Posts: 1915
15
Android Eclipse IDE Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try one thing.   Just change to_date to to_timestamp in your code and see if it makes any difference.
 
sushma swaraj
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok i will try to_timestamp once
 
sushma swaraj
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Its  also not working
 
Swastik Dey
Rancher
Posts: 1915
15
Android Eclipse IDE Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try to use PreparedStatement , and convert the date to sql timestamp and see if it makes any difference.
 
Rancher
Posts: 3753
40
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First, use a PreparedStatement.
That will at least ensure that your SQL is not having escaping problems.

Next, what is the exact format of the two date strings?
Personally, I would convert them to java.util.Date and have the INSERT code somewhere else entirely, like a Data Access Object.
That way your SQL doesn't have to care at all about date formats.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!