public class CarTypeExe {
public static void main(String[] args) {
run();
}
int index = 10;
private static void run() {
final Dao dao = DaoUtil.getDao();
long start = System.currentTimeMillis();
final List<CarType> list = new ArrayList<>();
dao.clear(CarType.class);
try {
IRowReader<Object> reader = new IRowReader<Object>() {
@Override
public Map<String, Object> getRows(int sheetIndex, int curRow, List<Object> rowList) {
System.out.println("ROWS="+curRow + " ");
if (curRow == 0) {
return null;
}
for (int i = 0; i < rowList.size(); i++) {
System.out.print(rowList.get(i) + ",");
}
System.out.println();
//
CarType carType = new CarType();
carType.setLevel_id(getCellValue(rowList,"A"));
carType.setYpc_id(0);
carType.setInitials("A");
carType.setBrand(getCellValue(rowList,"C"));
carType.setFactory(getCellValue(rowList,"B"));
carType.setCars(getCellValue(rowList,"D"));
carType.setYear(getCellValue(rowList,"M"));
carType.setDisplacement(getCellValue(rowList,"S"));
carType.setSale_name(carType.getFactory() + " " + carType.getCar_type() + " " + carType.getYear() + " " + getCellValue(rowList,"F"));
carType.setCar_type(getCellValue(rowList,"E"));
carType.setYear_model(getCellValue(rowList,"G"));
carType.setChassis(null);
//carType.setEngine(getCellValue(rowList,"GR"));
carType.setIntake_type(getCellValue(rowList,"T"));
carType.setGearbox_type(getCellValue(rowList,"AB"));
carType.setGearbox_remark(getCellValue(rowList,"AC"));
//carType.setBrand_logo_small(getCellValue(rowList,"GG"));
list.add(carType);
if (list.size() % 1000 == 0) {
Trans.exec(new Atom(){
@Override
public void run() {
dao.fastInsert(list);
list.clear();
}
});
}
return null;
}
private String getCellValue(List<Object> rowList,String col) {
Object object = rowList.get(ExcelColumn.excelColStrToNum(col));
if(object==null){
return "";
}
return object.toString();
}
};
new ExcelReaderUtil().readExcel(reader, GlobalContext.EXCEL07_EXTENSION, "C:/Users/King/Downloads/车型数据.xlsx", null, 1, 0, 1, "yyyyMMdd");
if (list.size() > 0) {
Trans.exec(new Atom(){
@Override
public void run() {
dao.fastInsert(list);
list.clear();
}
});
}
System.out.println(System.currentTimeMillis() - start);
} catch (Exception e) {
e.printStackTrace();
}
}
}
console.log
2017-11-16 15:57:4.121 DEBUG [main] SQLException
java.sql.BatchUpdateException: Cannot execute statement: impossible to write to binary log since BINLOG_FORMAT = STATEMENT and at least one table uses a storage engine limited to row-based logging. InnoDB is limited to row-logging when transaction isolation level is READ COMMITTED or READ UNCOMMITTED.
at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:2055)
at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:1467)
at org.nutz.dao.impl.sql.run.NutDaoExecutor._runPreparedStatement(NutDaoExecutor.java:322)
at org.nutz.dao.impl.sql.run.NutDaoExecutor.exec(NutDaoExecutor.java:90)
at org.nutz.dao.DaoInterceptorChain.doChain(DaoInterceptorChain.java:66)
at org.nutz.dao.impl.interceptor.DaoLogInterceptor.filter(DaoLogInterceptor.java:22)
at org.nutz.dao.DaoInterceptorChain.doChain(DaoInterceptorChain.java:64)
at org.nutz.dao.DaoInterceptorChain.invoke(DaoInterceptorChain.java:139)
at org.nutz.dao.impl.sql.run.NutDaoRunner.runCallback(NutDaoRunner.java:147)
at org.nutz.dao.impl.sql.run.NutDaoRunner._runWithTransaction(NutDaoRunner.java:93)
at org.nutz.dao.impl.sql.run.NutDaoRunner._run(NutDaoRunner.java:77)
at org.nutz.dao.impl.sql.run.NutDaoRunner$1.run(NutDaoRunner.java:63)
at org.nutz.trans.Trans.exec(Trans.java:174)
at org.nutz.dao.impl.sql.run.NutDaoRunner.run(NutDaoRunner.java:61)
at org.nutz.dao.impl.DaoSupport.run(DaoSupport.java:239)
at org.nutz.dao.impl.DaoSupport._exec(DaoSupport.java:247)
at org.nutz.dao.impl.EntityOperator.exec(EntityOperator.java:50)
at org.nutz.dao.impl.NutDao.fastInsert(NutDao.java:201)
at module.cartype.CarTypeExe$1$1.run(CarTypeExe.java:63)
at org.nutz.trans.Trans.exec(Trans.java:174)
at org.nutz.trans.Trans.exec(Trans.java:132)
at module.cartype.CarTypeExe$1.getRows(CarTypeExe.java:60)
at excel.read.Excel2007Reader.endElement(Excel2007Reader.java:271)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:609)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1782)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2973)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:606)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:117)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:848)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:777)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)
at excel.read.Excel2007Reader.execute(Excel2007Reader.java:168)
at excel.read.Excel2007Reader.processOneSheet(Excel2007Reader.java:112)
at excel.ExcelReaderUtil.readExcel(ExcelReaderUtil.java:55)
at module.cartype.CarTypeExe.run(CarTypeExe.java:79)
at module.cartype.CarTypeExe.main(CarTypeExe.java:19)
Caused by: java.sql.SQLException: Cannot execute statement: impossible to write to binary log since BINLOG_FORMAT = STATEMENT and at least one table uses a storage engine limited to row-based logging. InnoDB is limited to row-logging when transaction isolation level is READ COMMITTED or READ UNCOMMITTED.
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1086)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4237)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4169)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2617)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2778)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2834)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2156)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2441)
at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:2007)
... 37 more
org.nutz.dao.DaoException: !Nutz SQL Error: 'INSERT INTO car_type_new(level_id,ypc_id,initials,brand,factory,cars,year,displacement,sale_name,car_type,year_model,chassis,engine,intake_type,gearbox_type,gearbox_remark,brand_logo_small) VALUES('ELS0466A0001',0,'A','劳斯莱斯','劳斯莱斯','Ghost [古思特]','2009','6.6','劳斯莱斯 null 2009 6.6T 自动 标准版','Ghost [古思特]','2010','NULL','NULL','涡轮增压','自动','自动变速器(AT)','NULL') '
PreparedStatement:
'INSERT INTO car_type_new(level_id,ypc_id,initials,brand,factory,cars,year,displacement,sale_name,car_type,year_model,chassis,engine,intake_type,gearbox_type,gearbox_remark,brand_logo_small) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) '
CaseMessage=Cannot execute statement: impossible to write to binary log since BINLOG_FORMAT = STATEMENT and at least one table uses a storage engine limited to row-based logging. InnoDB is limited to row-logging when transaction isolation level is READ COMMITTED or READ UNCOMMITTED.
at org.nutz.dao.impl.sql.run.NutDaoExecutor.exec(NutDaoExecutor.java:104)
at org.nutz.dao.DaoInterceptorChain.doChain(DaoInterceptorChain.java:66)
at org.nutz.dao.impl.interceptor.DaoLogInterceptor.filter(DaoLogInterceptor.java:22)
at org.nutz.dao.DaoInterceptorChain.doChain(DaoInterceptorChain.java:64)
at org.nutz.dao.DaoInterceptorChain.invoke(DaoInterceptorChain.java:139)
at org.nutz.dao.impl.sql.run.NutDaoRunner.runCallback(NutDaoRunner.java:147)
at org.nutz.dao.impl.sql.run.NutDaoRunner._runWithTransaction(NutDaoRunner.java:93)
at org.nutz.dao.impl.sql.run.NutDaoRunner._run(NutDaoRunner.java:77)
at org.nutz.dao.impl.sql.run.NutDaoRunner$1.run(NutDaoRunner.java:63)
at org.nutz.trans.Trans.exec(Trans.java:174)
at org.nutz.dao.impl.sql.run.NutDaoRunner.run(NutDaoRunner.java:61)
at org.nutz.dao.impl.DaoSupport.run(DaoSupport.java:239)
at org.nutz.dao.impl.DaoSupport._exec(DaoSupport.java:247)
at org.nutz.dao.impl.EntityOperator.exec(EntityOperator.java:50)
at org.nutz.dao.impl.NutDao.fastInsert(NutDao.java:201)
at module.cartype.CarTypeExe$1$1.run(CarTypeExe.java:63)
at org.nutz.trans.Trans.exec(Trans.java:174)
at org.nutz.trans.Trans.exec(Trans.java:132)
at module.cartype.CarTypeExe$1.getRows(CarTypeExe.java:60)
at excel.read.Excel2007Reader.endElement(Excel2007Reader.java:271)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:609)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1782)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2973)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:606)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:117)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:848)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:777)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)
at excel.read.Excel2007Reader.execute(Excel2007Reader.java:168)
at excel.read.Excel2007Reader.processOneSheet(Excel2007Reader.java:112)
at excel.ExcelReaderUtil.readExcel(ExcelReaderUtil.java:55)
at module.cartype.CarTypeExe.run(CarTypeExe.java:79)
at module.cartype.CarTypeExe.main(CarTypeExe.java:19)
Caused by: java.sql.BatchUpdateException: Cannot execute statement: impossible to write to binary log since BINLOG_FORMAT = STATEMENT and at least one table uses a storage engine limited to row-based logging. InnoDB is limited to row-logging when transaction isolation level is READ COMMITTED or READ UNCOMMITTED.
at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:2055)
at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:1467)
at org.nutz.dao.impl.sql.run.NutDaoExecutor._runPreparedStatement(NutDaoExecutor.java:322)
at org.nutz.dao.impl.sql.run.NutDaoExecutor.exec(NutDaoExecutor.java:90)
... 34 more
Caused by: java.sql.SQLException: Cannot execute statement: impossible to write to binary log since BINLOG_FORMAT = STATEMENT and at least one table uses a storage engine limited to row-based logging. InnoDB is limited to row-logging when transaction isolation level is READ COMMITTED or READ UNCOMMITTED.
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1086)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4237)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4169)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2617)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2778)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2834)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2156)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2441)
at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:2007)
... 37 more