Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

inserting date into Oracle

843854May 6 2005 — edited May 6 2005
Hi everyone !
I am trying to insert current date as well as a due date into the oracle database. I figured out how to calculate the date. But, then when i try to insert the record, the result set gets stuck at executequery. It doesnt display any error either. Besides, that when I copy paste the query in oracle, it works !

My code is :
Calendar calendar = new GregorianCalendar();
Date date = calendar.getTime();
DateFormat format3 = new SimpleDateFormat( "dd/MMM/yyyy" );

int numberOfDays = 10;
calendar.add(GregorianCalendar.DATE, numberOfDays);

Object TempObj
String a2="V1";
String a3="C1";
char c ='i';

TempObj.InsertDateTemp(a3,a2,format3.format(calendar.getTime()),c);
****************
Main Class
public void InsertDateTemp(String CID,String VID,String string1,char c1) throws SQLException{
String SQL = null;
try{

SQL="INSERT INTO rental VALUES ( '"+ CID + "','"+ VID+"','"+string1+"','"+c1+"')";

System.out.println(SQL);
rs=statement.executeQuery(SQL); // Gets stuck right here...doesnt move neither
// shows any errors
rs.close();
conn.close();
}catch(SQLException e)
{}
Also, the corresponding data types in the oracle table is:
----------------------------------------- -------- ----------------------------
CID VARCHAR2(5)
VID VARCHAR2(5)
DUEDATE NOT NULL DATE
STATUS NOT NULL CHAR(2)
-------------------------------------------------
Is it because I am using the data type as String and not Date ??
Please help.....
Thank You .
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 3 2005
Added on May 6 2005
8 comments
531 views