- 关于mysql存储过程报 1064 syntax 错误异常,报错问题由于结束符号转移导致的,可在存储过程前后加上 delimiter // // 解决
delimiter //
存储过程代码....
//
- Connection is not avalible 连接不够的情况排查
#当前全部的连接数
SHOW FULL PROCESSLIST;
#查询最大连接数
SHOW VARIABLES like 'max_connections';
-- 设置最大连接数,根据需要进行设置
set GLOBAL max_connections=200
SHOW VARIABLES LIKE '%max_connections%';
2 调大超时时间 空闲连接 ,若遇到慢sql问题,则要进行排查处理,实在处理不了的则调整超时时间
3.打印堆栈信息 查看线程池配置,初始线程和最大线程数据,在高并发业务情况
jps 列出主类的pid
jstack -l pid> /tmp/jstack001.txt(jps对应的jar启动线程主类)
下载文件:sz /tmp/jstack001.txt
排查系统mysql ,排查线程是否设置合理 (不恰当的线程设置会导致占满连接不释放导致无法拿到连接)
Map<String, List<User>> collect = objects.stream().collect(Collectors.groupingBy(User::getName));
git提交代码换行问题
设置换行符(提交时再比对文件)
git config --global core.autocrlf=true
设置邮箱和用户名
Git config --global user.name “”
Git config --global user.email “
SQL
1.插入语句
start transaction ;
INSERT INTO product.config_property (property_key, property_type, property_value, property_value1, property_value2, property_value3, status) VALUES ( 'ext_url', 'out_url', 'http://127.0.0.1:8082/getZipFile', null, null, null, 0);
INSERT INTO product.config_property (property_key, property_type, property_value, property_value1, property_value2, property_value3, status) VALUES ( 'oms_url', 'out_url', 'http://127.0.0.1:8082/getZipFile', null, null, null, 0);
commit ;
或者
start transaction ;
INSERT INTO product.config_property (property_key, property_type, property_value, property_value1, property_value2, property_value3, status) VALUES ( 'ext_url', 'out_url', 'http://127.0.0.1:8082/getZipFile', null, null, null, 0),( 'oms_url', 'out_url', 'http://127.0.0.1:8082/getZipFile', null, null, null, 0);
commit ;
2.修改表字段或者添加(少量数据)
alter table check_config add column check_model varchar(200) comment '校验模型' after check_order;
alter table check_config rename column check_class_name to check_model_class;
alter table check_config drop check_model_class;
3.创建索引
create index idx_property_key on config_property(property_key);
drop index idx_property_key on config_property;
create unique index uq_property_key on config_property(property_key);
drop index uq_property_key on config_property ;
如果创建独立索引添加时重复
第一种更新数据
INSERT INTO product.config_property (property_key, property_type, property_value, property_value1, property_value2, property_value3, status) VALUES ( '01_url', 'out_url', 'http://127.0.0.1:8082/getZipFile', null, null, null, 0),( '02_url', 'out_url', 'http://127.0.0.1:8082/getZipFile', null, null, null, 0)
on duplicate key update create_time=now(),property_value2=values(property_value2)
第二种忽略数据 加IGNORE 忽略
INSERT IGNORE INTO product.config_property (property_key, property_type, property_value, property_value1, property_value2, property_value3, status) VALUES ( '01_url', 'out_url', 'http://127.0.0.1:8082/getZipFile', null, null, null, 0),( '02_url', 'out_url', 'http://127.0.0.1:8082/getZipFile', null, null, null, 0)
4其他
<![CDATA[ 内容 ]]]>
数字比对:<if test="status!=null and status=='0'.toString()"> status=#{status} </if>
select now() -interval 10 minute ;
select date_format(create_time,'%Y-%m-%d %H:%i:%S') create_time from check_config;
select date_format(create_time,'%Y-%m-%d 00:00:00') create_time from check_config;
select date_format(create_time,'%Y-%m-%d 23:59:59') create_time from check_config;
select now() -interval 10 minute ;
-- js 数组转逗号分割 var ids=[] ids=ids.join(',');
切分
ids=ids.split(',');
输入框添加placeholder
$("#user_name").next('span').children(":first").attr('placeholder','请输入搜索内容');
重置参数
$('#start_time').datetimebox('setValue',null);
$("#user_name").textbox('setValue','')
$('#dg').datagrid('load',{
user_name:$("#user_name").textbox('getValue')
})
document.getElementById("user_name").innerText='success'
$('#dg').datagrid({
title:'数据访问',
nowrap:true,
striped:true,
remoteSort:false
pagination:true,
rownumbers:true,
autoRowHeight:true,
pagePosition:'top',
toolbar:null,
singleSelect:true,
url:'',
method:'post',
queryParams:{
user_name:$("#user_name").textbox('getValue')
},
colums:[[
{field:'ck',checkbox:true},
{field:'id',hidden:true},
{field:'user_name',title:'用户名'},
]]
})
$.ajax({
type:"get",
url:'',
success:function(data){
}
})
按键弹起去空格
οnkeyup="this.value=this.value.replace(/^\s+|\s+$/g,'')"
===============linux 安装字体文件===============
步骤1:将c盘字体文件放入到 : /usr/share/fonts C:\Windows\Fonts\simsun.ttc
sftp> put C:\Users\haoha\Desktop\upload\simsun.ttc
[root@localhost ~]# mv ./simsun.ttc /usr/share/fonts/simsun
步骤2:刷新缓存字体文件:fc-cache /usr/share/fonts
文件转字字节数组
<dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>1.18.12</version> <scope>provided</scope> </dependency>
<dependency> <groupId>commons-io</groupId> <artifactId>commons-io</artifactId> <version>2.11.0</version> </dependency>
File file = new File(""); try (FileInputStream fileInputStream = new FileInputStream(file)) { byte[] bytes = IOUtils.toByteArray(fileInputStream); } catch (Exception e) { log.error(e.getMessage()); }
===redis,lettuce连接池,数据库连接池配置=====
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-redis</artifactId> </dependency> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-pool2</artifactId> </dependency>
<dependency> <groupId>com.google.code.gson</groupId> <artifactId>gson</artifactId> <version>2.8.2</version> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>8.0.19</version> </dependency> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>1.18.12</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> <version>3.12.0</version> </dependency>
spring.datasource.url=jdbc:mysql://localhost:3306/product?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai spring.datasource.username=root spring.datasource.password= spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver # redis spring.redis.host=localhost spring.redis.port=6379 spring.redis.lettuce.pool.max-idle=8 spring.redis.lettuce.pool.min-idle=2 spring.datasource.type=com.zaxxer.hikari.HikariDataSource ## Hikari 连接池配置 ------ 详细配置请访问:https://github.com/brettwooldridge/HikariCP ## 最小空闲连接数量 spring.datasource.hikari.minimum-idle=5 ## 空闲连接存活最大时间,默认600000(10分钟) spring.datasource.hikari.idle-timeout=180000 ## 连接池最大连接数,默认是10 spring.datasource.hikari.maximum-pool-size=10 ## 此属性控制从池返回的连接的默认自动提交行为,默认值:true spring.datasource.hikari.auto-commit=true ## 此属性控制池中连接的最长生命周期,值0表示无限生命周期,默认1800000即30分钟 spring.datasource.hikari.max-lifetime=1800000 ## 数据库连接超时时间,默认30秒,即30000 spring.datasource.hikari.connection-timeout=30000 spring.datasource.hikari.connection-test-query=SELECT 1 ## 连接池名称 spring.datasource.hikari.pool-name=hikari0001DbPool #================== HikariDataSource连接池配置 end =============== @SpringBootApplication @EnableAsync @MapperScan("com.check.dao") mybatis.mapper-locations=classpath:/mapper/*.xml
@Configuration public class RedisConfig { @Bean public RedisTemplate<String,String> getRedisTemplate(){ RedisTemplate<String, String> redisTemplate = new RedisTemplate<>(); LettuceConnectionFactory connectionFactory = new LettuceConnectionFactory(); redisTemplate.setConnectionFactory(connectionFactory); return redisTemplate; } }
springBean获取
@Component public class SpringBeanUtils implements ApplicationContextAware { private ApplicationContext applicationContext; @Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { this.applicationContext = applicationContext; } public Object getBean(String name) { return applicationContext.getBean(name); } public <T> T getBean(Class<T> aclass) { return applicationContext.getBean(aclass); } }
JS弹出框换行 <br/>
分页:int total=(count+100-1)/100;
for(int i=1;i<total;i++){
int start =(i-1)*100;
int end =100
}
==============kafka命令===============
-- 查看所有组
[root@localhost bin]# ./kafka-consumer-groups.sh --bootstrap-server 192.168.23.12:9092 --describe
-- 查看所有组的消费情况
[root@localhost bin]# ./kafka-consumer-groups.sh --bootstrap-server 192.168.23.12:9092 --describe --all-groups
-- 所有消费组成员信息
[root@localhost bin]# ./kafka-consumer-groups.sh --bootstrap-server 192.168.23.12:9092 --describe --all-groups --members
-- 重置offset
[root@localhost bin]# ./kafka-consumer-groups.sh --bootstrap-server 192.168.23.12:9092 --describe --all-groups
Consumer group 'groupA' has no active members.
GROUP TOPIC PARTITION CURRENT-OFFSET LOG-END-OFFSET LAG CONSUMER-ID HOST CLIENT-ID
groupA topic-demo 0 30000 61020 31020 - - -
[root@localhost bin]# ./kafka-consumer-groups.sh --bootstrap-server 192.168.23.12:9092 --group groupA --reset-offsets --to-offset 30000 --topic topic-demo --execute
GROUP TOPIC PARTITION NEW-OFFSET
groupA topic-demo 0 30000
GROUP CONSUMER-ID HOST CLIENT-ID #PARTITIONS
groupA consumer-1-67d636a6-59a7-4542-a423-37c7180d5e59 /192.168.23.1 consumer-1 1
groupA consumer-2-59e2ece4-a673-44a1-8106-488e290300cf /192.168.23.1 consumer-2 0
groupA consumer-4-ac1d3b4d-f374-4036-b20f-b83ec6e6cf2a /192.168.23.1 consumer-4 0
groupA consumer-3-98fc396e-abfd-473a-b3bb-d3e41e3d7431 /192.168.23.1 consumer-3 0
Consumer group 'groupA' has no active members.
GROUP TOPIC PARTITION CURRENT-OFFSET LOG-END-OFFSET LAG CONSUMER-ID HOST CLIENT-ID
groupA topic-demo 0 51020 61020 10000 - - -
数字校验正则: private static final Pattern NUMBER_REG = Pattern.compile("^-?\\d+(\\.\\d+)?$");