This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes JDBC and the fly likes SQL Column Date Type insertion problem Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "SQL Column Date Type insertion problem" Watch "SQL Column Date Type insertion problem" New topic
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
    
  11

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
    
  11

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
    
  52

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]
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: SQL Column Date Type insertion problem
 
Similar Threads
DataTime conversion
how to write this query
gps week/seconds conversion
Converting string to date with extra strings
cannot insert datetime type