sql - Update Date Field in MS Access Using Java -


i creating java application ms access database in windows 7. fine when doing select query. however, when update date field of ms access db java application, throws sql exception. below ms access table structure , java code. in advance.

[![this ms access table date field structure][1]][1] 

my java source code here:

string qry1="select isometric_number tbl_weld_details line_number='0470-52-adb-17034001-01' , sheet_number='1/2'";             try{                 connection con=database.get_connection();                 preparedstatement ps = con.preparestatement(qry1);                 resultset rs = ps.executequery();                 if(rs.next())                 {                     string iso_no = rs.getstring(1);                                              string qry2="update tbl_weld_register set weld_date=?,welders_root1=?,welders_cap1=? isometric_number=? , spool_no=? , weld_number=?";                      preparedstatement ps1 = con.preparestatement(qry2);                                           ps1.setstring(1, "29/12/2016");  //problem here                     ps1.setstring(2, "cheliyan");                     ps1.setstring(3, "raja");                     ps1.setstring(4, iso_no);                     ps1.setstring(5, "spl-1");                     ps1.setstring(6, "1");                     system.out.print("query2===========>"+qry2);                     int res1=ps1.executeupdate();                                             if(res1 > 0)                     {                         issuccess = true;                     }                  }              }             catch (exception e)             {                 // todo auto-generated catch block                 e.printstacktrace();             } 

i error in logs:

java.sql.sqlexception: [microsoft][odbc microsoft access driver]  error date: kindly check weld date or nde date...  @ sun.jdbc.odbc.jdbcodbc.createsqlexception(unknown source) @ sun.jdbc.odbc.jdbcodbc.standarderror(unknown source) @ sun.jdbc.odbc.jdbcodbc.sqlexecute(unknown source) @ sun.jdbc.odbc.jdbcodbcpreparedstatement.execute(unknown source) @ sun.jdbc.odbc.jdbcodbcpreparedstatement.executeupdate(unknown source) @ dao.employeetmsdao.updatejointnostatus(employeetmsdao.java:76) 

use iso sequence (yyyy-mm-dd) , wrap in octothorps obtain proper string expression date value:

ps1.setstring(1, "#2016/12/29#");  

Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -