jdbc预编译缓存加速sql执行

PreparedStatement可以防止sql注入,这个大家都知道;今天来聊聊他对性能的提升。

SQL syntax

SQL syntax for prepared statements is based on three SQL statements:

阅读更多

jdbc-batching

批量处理

批量插入

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/**
* insert into words (word) values(?) -> stopwatch = 66487
*/
@Test
@SneakyThrows
public void testBatch() {
String connectString = "jdbc:mysql://localhost/test?user=root&password=toor&useLocalSessionState=true&useSSL=false";
Class.forName("com.mysql.jdbc.Driver")
.newInstance();
try (Connection conn = DriverManager.getConnection(connectString)) {
//插入100000条测试代码
Stopwatch stopwatch = Stopwatch.createStarted();
try (PreparedStatement psts = conn.prepareStatement("insert into words (`word`) VALUES(?)")) {
for (int i = 0; i < 100000; i++) {
psts.setString(1, "123");
psts.addBatch();
}
psts.executeBatch();
stopwatch.stop();
System.out.println("stopwatch = " + stopwatch.elapsed(TimeUnit.MILLISECONDS));
}
}
}

阅读更多

mysql jdbc驱动参数性能调优

SSL对性能的影响

现象

我将驱动从

阅读更多

crontab和邮件

crontab是什么

linux下的定时任务执行

语法

1
2
3
4
5
6
7
8
*     *     *   *    *        command to be executed
- - - - -
| | | | |
| | | | +----- day of week (0 - 6) (Sunday=0)
| | | +------- month (1 - 12)
| | +--------- day of month (1 - 31)
| +----------- hour (0 - 23)
+------------- min (0 - 59)

阅读更多

配置sudo.log

日志

配置 sudo.log

1
2
[root@yd-test-01-pms log]# touch /var/log/sudo.log
[root@yd-test-01-pms log]# visudo

阅读更多

Spring中bean name重复的问题

现象

1
2
3
4
5
6
7
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.atour.oss.dao.mapper.OssFileMapper.insert

at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:227)
at org.apache.ibatis.binding.MapperMethod.<init>(MapperMethod.java:49)
at org.apache.ibatis.binding.MapperProxy.cachedMapperMethod(MapperProxy.java:65)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:58)
at com.sun.proxy.$Proxy188.insert(Unknown Source)

阅读更多

Feign方法级别的超时

Feign方法级别的超时

    阅读更多