Do easy-to-buy Web projects, due to the database insertion system time is not understood, often encountered problems:
1, java.sql.sqlexception:ora-01861: Text and Format strings do not match,
Cause: Due to the incorrect acquisition system time type, it should be systdate
The following describes the insertion of the current system time for Oracle, DB2, SQL Server, MySQL database
For example, there are two fields in table table,table: Name, Makedate
1.oracle:
the insertion system time should be sysdate:
insert into table (name,makedate) VALUES (' Test ', sysdate);
2.DB2:
The insertion system time should be current timestamp and the Makedate data type is timestamp
insert into table (name,makedate) VALUES (' Test ', current timestamp);
3.SqlServer:
Insert system time should be getdate ()
insert into table (name,makedate) VALUES (' Test ', GETDATE ());
4.MySQL:
Insert System time should:
now (): Returns the current datetime with ' Yyyy-mm-dd hh:mm:ss ', which can be stored directly in the DateTime field.
curdate (): ' YYYY-MM-DD ' format returns today's date, which can be stored directly in the Date field.
insert into table (name,makedate) VALUES (' Test ', now ());
Oracle, DB2, SQL Server, MySQL database insert current system time