2018-08-17 09:21

@JFinal 如果上传文件大小 超出系统设置大小 抛异常前台就接收不到返回的json 如果文件在合理范围内 就可以接收返回的json ,是不是抛异常改变了输出方式呀
用jetty方式启动没问题 Tomcat方式就有上面那个问题 很奇怪

2018-07-30 12:46

我分别在833行 和 869行 打了两个断点 从第一个断点调到第二个断点 耗时就是19秒左右

2018-07-30 12:33

@JFinal protected int[] batch(Config config, Connection conn, String sql, String columns, List list, int batchSize) throws SQLException {
if (list != null && list.size() != 0) {
Object element = list.get(0);
if (!(element instanceof Record) && !(element instanceof Model)) {
throw new IllegalArgumentException("The element in list must be Model or Record.");
} else if (batchSize < 1) {
throw new IllegalArgumentException("The batchSize must more than 0.");
} else {
boolean isModel = element instanceof Model;
String[] columnArray = columns.split(",");

for(int i = 0; i < columnArray.length; ++i) {
columnArray[i] = columnArray[i].trim();
}

boolean isInTransaction = config.isInTransaction();
int counter = 0;
int pointer = 0;
int size = list.size();
int[] result = new int[size];
PreparedStatement pst = conn.prepareStatement(sql);

for(int i = 0; i < size; ++i) {
Map map = isModel ? ((Model)list.get(i))._getAttrs() : ((Record)list.get(i)).getColumns();

for(int j = 0; j < columnArray.length; ++j) {
Object value = map.get(columnArray[j]);
if (value instanceof Date) {
if (value instanceof java.sql.Date) {
pst.setDate(j + 1, (java.sql.Date)value);
} else if (value instanceof Timestamp) {
pst.setTimestamp(j + 1, (Timestamp)value);
} else {
Date d = (Date)value;
pst.setTimestamp(j + 1, new Timestamp(d.getTime()));
}
} else {
pst.setObject(j + 1, value);
}
}

pst.addBatch();
++counter;
if (counter >= batchSize) {
counter = 0;
int[] r = pst.executeBatch();
if (!isInTransaction) {
conn.commit();
}

for(int k = 0; k < r.length; ++k) {
result[pointer++] = r[k];
}
}
}

int[] r = pst.executeBatch();
if (!isInTransaction) {
conn.commit();
}

for(int k = 0; k < r.length; ++k) {
result[pointer++] = r[k];
}

DbKit.close(pst);
return result;
}
} else {
return new int[0];
}
}
这个方法遍历属性的时候很耗时间 ,commit的时候很快