| Author |
SQL Column Date Type insertion problem
|
Ravi Kiran Va
Ranch Hand
Joined: Apr 18, 2009
Posts: 2234
|
|
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 .
|
Save India From Corruption - Anna Hazare.
|
 |
Christophe Verré
Sheriff
Joined: Nov 24, 2005
Posts: 14672
|
|
|
Use a PreparedStatement and setDate(int, Date) instead of hard coding the values.
|
[My Blog]
All roads lead to JavaRanch
|
 |
Ravi Kiran Va
Ranch Hand
Joined: Apr 18, 2009
Posts: 2234
|
|
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
Joined: Nov 24, 2005
Posts: 14672
|
|
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
Joined: Apr 18, 2009
Posts: 2234
|
|
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
Marshal
Joined: Jul 20, 2005
Posts: 8145
|
|
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.
|
[My Blog] [JavaRanch Journal]
|
 |
 |
|
|
subject: SQL Column Date Type insertion problem
|
|
|