• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

SQL Column Date Type insertion problem

 
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ,

I always face problem when inserting Date into a Date Type column Type .

Assume ,that i have a table like this as shown below :


Name Type
TXN_ID VARCHAR2(10)
IN_TIME DATE


when i tried to work with the below code , it gave a sqlexception saying that , Invalid month .




I also tried with using SimpleDateFormat , in which it also gave a error .




Exception in thread "main" java.text.ParseException: Unparseable date: "11-11-2005"
at java.text.DateFormat.parse(Unknown Source)


So please tell me , how can i insert a date in SQL Oracle Database having a Date Column .

Thanks .
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Use a PreparedStatement and setDate(int, Date) instead of hard coding the values.
 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Use a PreparedStatement


hey , this is only for testing a standalone program .
Hey leave about the PreparedStatement right now , i am right now interested to work with Statement only , how is it possible to insert a Date into SQL Column of Date Type .

Thanks.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why wouldn't you use a PreparedStatement even to test a standalone program ?

Oh well... You can try this instead :


Hey


Doesn't sound very nice...
 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


you were being deviated from the actual question . doesn't need this .

Doesn't sound very nice...



Are you using any Talking buddies to hear these characters .
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ravi Kiran Va wrote:

you were being deviated from the actual question . doesn't need this .



No one was deviating from the question. The reply is appropriate for the question you asked.

Ravi Kiran Va wrote:

Doesn't sound very nice...



Are you using any Talking buddies to hear these characters .



You are crossing the Be Nice rule and that won't be tolerated. If you want help for your questions, please make sure that you don't repeat this attitude again.
reply
    Bookmark Topic Watch Topic
  • New Topic