JPA书写自定义sql(数据库为PG库)
自定义查询语句
@Query(value = "select * from user where test.name= :name AND test.passwd=:passwd",
nativeQuery = true)
Optional<Test> findByParam(@Param("name") String name, @Param("passwd") String passwd);
自定义插入语句
@Transactional
@Modifying //增删改必须有这个注解
@Query(value = "insert into test(create_date,name,passwd) VALUES
(NOW(),:name,:passwd)", nativeQuery = true)
int insertRecentInformation(@Param("name") String name,@Param("passwd") String passwd);
自定义更新语句
@Transactional
@Modifying
@Query(value = "update test set passwd = :passwd where create_date = to_date(cast(NOW()
as TEXT),'YYYY-MM-DD'), nativeQuery = true)
int updateRecentInformation(@Param("passwd ") String passwd );
JAVA读取EXCEL文件
获取文件流
Workbook workbook = null;
if (filename.endsWith(EXCEL2007)) {
workbook = new XSSFWorkbook(file.getInputStream());
}
if (filename.endsWith(EXCEL2003)) {
workbook = new HSSFWorkbook(file.getInputStream());
}
获取标签页
Sheet sheet = workbook.getSheetAt(0);
Sheet sheet1 = workbook.getSheet("SHEET1");
对标签页中某一个单元格进行获取
public static String processingCell(Row xssfRow, int i) {
String parent = "";
if ("".equals(xssfRow.getCell(i)) || xssfRow.getCell(i) == null) {
} else {
xssfRow.getCell(i).setCellType(CellType.STRING);
parent = String.valueOf(CharMatcher.WHITESPACE.
trimFrom(((xssfRow.getCell(i)).getStringCellValue())));
}
return parent;
}
对整个标签页内容进行获取,将每一行都转换为一个实体
public static List<Test> getDetailConfigures(Sheet sheet) {
List<Test> list = new ArrayList<>();
for (int i = 1; i <= sheet.getLastRowNum(); i++) {//从第二行读取到最后一行
Row row = sheet.getRow(i);
if (processingCell(row, 0) == null || "".equals(processingCell(row, 0))) {
break;
}
Test test= new Test();
test.setEn_name(processingCell(row, 0));
test.setCn_name(processingCell(row, 1));
test.setUnit(processingCell(row, 2));
test.setIsdisplay(Boolean.parseBoolean(processingCell(row, 3)));
test.setWay(processingCell(row, 4));
test.setOrder_chart(processingCell(row, 5));
test.setIs_chart(processingCell(row, 6));
list.add(test);
}
return list;
}
docker移动存储目录
查看docker存储使用情况
docker system df
删除docker缓存
docker system prune
停止docker服务
systemctl stop docker
移动docker存储目录至新目录
rsync -avz /var/lib/docker /data/docker/lib/
注:新目录需提前新建好,可根据具体情况修改目录
配置docker服务启动文件
vi /usr/lib/systemd/system/docker.service
在ExectStart 类末尾添加 “--graph /data/docker/lib/docker”,保存后退出
ExectStart=xxx --graph /data/docker/lib/docker
使docker配置生效,并启动服务
systemctl disable docker
systemctl enable docker
systemctl daemon-reload
systemctl start docker
查看docker服务的信息
docker info