So what I want to do is set a custom date along with the current time into the DATE type in the Oracle database. I get the string from textField in the form of mm/dd/yyyy
String tdate = textDate.getText().trim();
To simplify the details lets just insert the DATE into a small table.
Calendar calendar = Calendar.getInstance();
int hour = calendar.get(Calendar.HOUR);
int minute = calendar.get(Calendar.MINUTE);
int second = calendar.get(Calendar.SECOND);
String current_time = hour+":"+minute+":"+second;
now we have tdate as the string of date and current_time as the current time.
to put into a database with table defined as :
create table transaction(
tranaction_num integer,
time_of_transaction DATE);
now in jdbc
PreparedStatement pStmt = Conn.prepareStatement("insert into transaction values(?,?));
pStmt.setString(1, "1");
pStmt.setString(2, "to_date( '"+tdate+" "+current_time+"','mm/dd/yyyy hh24:mi:ss')");
pStmt.executeUpdate();
This gives me an error as below
ORA-01858: a non-numeric character was found where a numeric was expected
I know I am doing something wrong but I have tried so many things to get this working. I don't mind getting the current time some other way as long as it is working
Any help would be appreciated