日期类型
最后更新:2023-10-18 19:53:45
|
状态:未完成
有些数据库对数据类型要求比较严格,不能隐式转换,这时需要开启 ConfigTable.IS_AUTO_CHECK_METADATA = true;
这样在插入数据前可以检测列的数据类型,检测到数据类型才能实现正确的格式转换
例如Oracle
例如Oracle
row = new DataRow(); row.put("ID", "${SIMPLE_SEQ.NEXTVAL}"); row.put("NAME", "N"); //当前时间,如果要适配多种数据库环境尽量用SQL_BUILD_IN_VALUE,如果数据库明确可以写以根据不同数据库写成: row.put("REG_TIME","${now()}"); sysdate,getdate()等等 row.put("REG_TIME", JDBCAdapter.SQL_BUILD_IN_VALUE.CURRENT_TIME); qty = service.insert(table, row); set = service.querys(table); row = new DataRow(); row.put("ID", "${SIMPLE_SEQ.NEXTVAL}"); row.put("NAME", "N"); row.put("REG_TIME", new java.sql.Timestamp(System.currentTimeMillis())); qty = service.insert(table, row); row = new DataRow(); row.put("ID", "${SIMPLE_SEQ.NEXTVAL}"); row.put("NAME", "N"); row.put("REG_TIME", new java.sql.Date(System.currentTimeMillis())); qty = service.insert(table, row); //下面这两种如果不开启IS_AUTO_CHECK_METADATA会抛出异常 row = new DataRow(); row.put("ID", "${SIMPLE_SEQ.NEXTVAL}"); row.put("NAME", "N"); row.put("REG_TIME", new java.util.Date()); qty = service.insert(table, row); row = new DataRow(); row.put("ID", "${SIMPLE_SEQ.NEXTVAL}"); row.put("NAME", "N"); row.put("REG_TIME", DateUtil.format("yyyy-MM-dd HH:mm:ss")); qty = service.insert(table, row);