java.sql.SQLException: ORA-01861: 文字与格式字符串不匹配
SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date=new Date();
String dateTime = dateformat.format(date);
String update = "UPDATE userinfo SET lastlogin=to_date("+dateTime+",'yyyy-MM-dd HH:mi:ss'),logins=logins+1 where userid=" + userid;
String update1 = "INSERT into Log(username,uptime,lastip,content) VALUES('" + username + "','" + dateTime + "','" + lastip + "','登陆系统')";
java.sql.
SQLException: ORA-01861: 文字与格式字符串不匹配
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)
at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:573)
at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1891)
at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:1093)
at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:2047)
at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:1940)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2709)
at oracle.jdbc.driver.OracleStatement.executeUpdate(OracleStatement.java:796)
at org.gl.Login.service(Login.java:70)
70行为int n = sql1.executeUpdate(update1);
请问哪里错了,如何解决
------解决方案--------------------
应该对dateTime加单引号,这样写,"'"+dateTime+"'"