• Post Reply Bookmark Topic Watch Topic
  • New Topic

SQL Column Date Type insertion problem

 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • 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 .
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • 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
  • 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 Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • 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
  • 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 .
 
Jaikiran Pai
Sheriff
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • 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.
 
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
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!