Results 1 to 3 of 3
- 07-28-2010, 01:47 PM #1
Member
- Join Date
- Jul 2010
- Posts
- 18
- Rep Power
- 0
How to insert/update Date field in Oracle with java code
:confused:Dear All
I have to insert/update a date column while creating a new item, but the problem is i am able to insert/update only date but i need both date and time along with AM/PM.
By using these 3 lines i am able to insert/update only date.
java.util.Date date = new java.util.Date();
long dateLong = date.getTime();
stmtPrep.setDate(33, new java.sql.Date(dateLong));
Below code retrives the date exactly what i need but unable to pass in the statement:
DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss a");
java.util.Date d = (Date) new java.util.Date();
String stringdate = formatter.format(d);
String tmpdate = dateFormat();
stmtPrep.setString(33, tmpdate); -- I tried with setObject as well but same error coming.
Error is:
ORA-01830: date format picture ends before converting entire input string
Can u guide me how to get full date time with AM/PM?
- 07-28-2010, 03:34 PM #2
Moderator
- Join Date
- Jul 2010
- Location
- California
- Posts
- 1,609
- Rep Power
- 5
While the information about your db and code is lacking, I will ask why you need more than the the first date update...am/pm is already stored in the original Date object you used to call setDate, it just needs to be formatted when retrieved.
- 07-28-2010, 04:14 PM #3
Similar Threads
-
insert data from text field to jtable
By mackinas in forum New To JavaReplies: 2Last Post: 06-09-2010, 04:30 AM -
insert java code to SQL
By rashidzamani in forum JDBCReplies: 3Last Post: 08-18-2009, 01:07 PM -
Insert oracle rowtype
By Faheem_Ahmed in forum New To JavaReplies: 0Last Post: 02-28-2009, 07:12 AM -
how to insert date field read from Excel using JExcel to database
By saran123 in forum JDBCReplies: 1Last Post: 10-10-2008, 08:47 AM -
How to insert java Object in oracle database
By Thilkumar82 in forum Advanced JavaReplies: 9Last Post: 08-13-2008, 11:33 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks