File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes inserting a string containing  date into oracle table which has the date type field Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "inserting a string containing  date into oracle table which has the date type field" Watch "inserting a string containing  date into oracle table which has the date type field" New topic
Author

inserting a string containing date into oracle table which has the date type field

suchita jadhav
Greenhorn

Joined: Dec 05, 2004
Posts: 1
hi,
i have a html page which accepts the date from text box in dd/mm/yyyy format.
this date string is stored in string variable in next jsp page.
now how can i store this string variable into oracle table which has coloumn with date data type.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30123
    
150

Suchita,
Welcome to JavaRanch!

Take a look at the SimpleDateFormat class. This converts your String into a Date. Then you can use stmt.setDate() and let Oracle worry about the database format.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Shailesh Chandra
Ranch Hand

Joined: Aug 13, 2004
Posts: 1081

suchita ,

You can do it in either way either convery string into Date typoe in Java Code or Do it in Oracle.

To do same in oracle,simply you can use to_date function of oracle to covert your string into date type

Syntax is to_date(String,Format)

if you want to insert a date ie 06/12/2004 in dd/mm/yyyy format,
You can do same like this

insert into table_name(Date_column) values(to_date('06/12/2004','dd/mm/yyyy'))

thanks
[ December 06, 2004: Message edited by: Shailesh Chandra ]

Gravitation cannot be held responsible for people falling in love ~ Albert Einstein
 
 
subject: inserting a string containing date into oracle table which has the date type field
 
Similar Threads
Passing date and time using Timestamp.
java.sql.Timestamp to Oracle date
parsing in servlet
Date Conversion in SQL
SQL to retrieve date vals from ORA-DB