I have to insert a date in the database(oracle 8).I am using following peice of code: if(info.getLastUpdatedTime() == null ) { System.out.println("if:UPDTime in ejbcreate oucbean...."); pstmt.setDate(7,date);//date is defined as java.sql.Date } else { System.out.println("else:UPDTime in ejbcreate oucbean...."); pstmt.setDate(7,info.getLastUpdatedTime()); } The method getLastUpdatedTime() is defined to return a a java.util.Date.But I have to convert it to java.sql.Date before I issue an insert sql statement. Can anybody give me a peice of code that converts java.util.Date to java.sql.Date. (weblogic 5.1.0 oracle 8)
Thanks for the input Carl.Its working fine now and I can insert records in the database.
ammuswar kumar
Greenhorn
Joined: Aug 19, 2001
Posts: 27
posted
0
sir
i have a table in SQL-SERVER named as title this table has three fields 1.id 2.tdate----this is of the type datetime 3.content i am using JRUN 3.0 i want to make a javaservlet in which u have a text link Date todaysdate = new Date(); todays content; In the servlet : i am accepting this parameter as String a = request.getParameter("todaysdate");
i will the database connecion--------------------- then ' select * from title where tdate = 'a';
-----------but this not showing any result error; there is something wrong here in he compatitbility of 'a' with tdate
klein bottle
Greenhorn
Joined: Oct 28, 2003
Posts: 1
posted
0
if using JDBC-ODBC instead of pure JDBC it seems you must explicitly format the date // How to put a date into a sql database. 29 October 2003 //This is a repost, but theres a lot of suggestions out there, // This is the one that works (took me half a day to find that out) // I use sun.jdbc.odbc.JdbcOdbcDriver. (because my JB9 hates pure jdbc) // This is the ONLY method that works for me // original: Eddy Young Coding_MU