mirror of
https://gitee.com/huoyo/ko-time.git
synced 2025-12-06 16:58:26 +08:00
optimize the saver of database
This commit is contained in:
parent
012e7adc0d
commit
88f07794cd
@ -11,13 +11,11 @@ import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.lang.reflect.Parameter;
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -71,10 +69,7 @@ public class DataBase implements GraphService {
|
||||
methodNode.getRouteName(),
|
||||
methodNode.getMethodType().name()
|
||||
};
|
||||
long start1 = System.currentTimeMillis();
|
||||
DataBaseUtil.insert(getWriteConnection(),KoSqlConstant.addMethod, params);
|
||||
long end1 = System.currentTimeMillis();
|
||||
log.info("插入耗时" + (end1 - start1) / 1000.0);
|
||||
} else {
|
||||
if (methodNode.getMethodType() == MethodType.Controller && !StringUtils.isEmpty(methodNode.getRouteName())) {
|
||||
Object[] params = new Object[]{
|
||||
|
||||
@ -39,10 +39,4 @@ public class InvokedQueue {
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
InvokedQueue.add(new InvokedInfo());
|
||||
System.out.println(InvokedQueue.linkedList.size());
|
||||
InvokedQueue.linkedList.poll();
|
||||
System.out.println(InvokedQueue.linkedList.size());
|
||||
}
|
||||
}
|
||||
|
||||
@ -15,12 +15,12 @@ import java.util.logging.Logger;
|
||||
|
||||
public class DataBaseUtil {
|
||||
public static Logger log = Logger.getLogger(DataBaseUtil.class.toString());
|
||||
|
||||
static Map<String, ColumnInfo> tableInfoMap = new ConcurrentHashMap<>();
|
||||
|
||||
public static DataSource getDataSource() {
|
||||
return Context.getDataSource();
|
||||
}
|
||||
|
||||
public static int insert(String sql, Object[] values) {
|
||||
try {
|
||||
Connection connection = getDataSource().getConnection();
|
||||
@ -41,7 +41,7 @@ public class DataBaseUtil {
|
||||
int n = statement.executeUpdate();
|
||||
return n;
|
||||
} catch (SQLIntegrityConstraintViolationException e) {
|
||||
log.warning("Duplicate id:" + values[0]);
|
||||
log.info("Duplicate Method id:" + values[0]);
|
||||
} catch (SQLException throwables) {
|
||||
throwables.printStackTrace();
|
||||
} finally {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user