java - "Literal does not match the format string" error -


when try execute below code gives me java.sql.sqlexception: ora-01861: literal not match format string error.

i trying copy of column values customer1_details table customer2_details table. columns datatype trying move timestamp(6) time_registered, date_discharged columns , datatype date_of_birth column date

    try     {         connection conn=address.getoracleconnection();           int id = 1;              date dob = null;         timestamp timereg = null,datedischarged = null;          statement stmt=conn.createstatement();         resultset res=stmt.executequery("select time_registered,date_discharged,date_of_birth customer1_details customer_id = '"+id+"' ");              if(res.next())              {                        timereg=res.gettimestamp("time_registered");                             datedischarged=res.gettimestamp("date_discharged");                   dob=res.getdate("date_of_birth");                   }                            string sql1="insert customer2_details(time_registered_3,date_discharged_3,date_of_birth,customer_id) "     + "values('"+timereg+"','"+datedischarged+"','"+dob+"','"+id+"') ";          preparedstatement pst=conn.preparestatement(sql1);         pst.executeupdate();         pst.close();                conn.close();     }     catch(exception e)     {            system.out.print(e);           }   

it more helpful if provides answer without using insert ... select ... statement.

you can in 1 statement query like:

"insert customer2_details (time_registered_3,date_discharged_3,date_of_birth,customer_id) select time_registered,date_discharged,date_of_birth, customer_id customer1_details customer_id = '"+id+"' " 

Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -