• Home

  • 归档

  • 分类

  • 标签
Keep Coding
Keep Coding

04月
14
问题记录

Could not resolve host:mirrorlist.centos.org; Unknown error

发表于 2019-04-14 • 分类于 问题记录

执行 yum 命令时报:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock32 error was
14: curl#6 - "Could not resolve host: mirrorlist.centos.org; Unknown error"

One of the configured repositories failed (Unknown),
and yum doesn't have enough cached data to continue. At this point the only
safe thing yum can do is fail. There are a few ways to work "fix" this:

1. Contact the upstream for the repository and get them to fix the problem.

2. Reconfigure the baseurl/etc. for the repository, to point to a working
upstream. This is most often useful if you are using a newer
distribution release than is supported by the repository (and the
packages for the previous distribution release still work).

3. Disable the repository, so yum won't use it by default. Yum will then
just ignore the repository until you permanently enable it again or use
--enablerepo for temporary usage:

yum-config-manager --disable <repoid>

4. Configure the failing repository to be skipped, if it is unavailable.
Note that yum will try to contact the repo. when it runs most commands,
so will have to try and fail each time (and thus. yum will be be much
slower). If it is a very temporary problem though, this is often a nice
compromise:

yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true

配置下网络即可。

阅读全文 »
04月
03
数据库

SQL Server row_number()

发表于 2019-04-03 • 分类于 数据库

row_number() over (order by clause)

在 SQL SERVER 的 row_number() over() 中使用 order by 对 select 查询的结果进行排序,并为每一行赋予一个连续的编号。

对于数据:

1
2
3
4
5
6
7
8
id|user_id|name   |
--|-------|-------|
1| 1|用户1的请假1|
2| 2|用户2的请假1|
3| 3|用户3的请假1|
4| 2|用户2的请假2|
5| 2|用户2的请假3|
6| 1|用户1的请假2|

使用:

1
select ROW_NUMBER() over(order by user_id) rowNum, id, user_id, name from leave

查询结果为:

1
2
3
4
5
6
7
8
rowNum|id|user_id|name   |
------|--|-------|-------|
1| 1| 1|用户1的请假1|
2| 6| 1|用户1的请假2|
3| 2| 2|用户2的请假1|
4| 4| 2|用户2的请假2|
5| 5| 2|用户2的请假3|
6| 3| 3|用户3的请假1|

这里使用 rowNum 是一个从 1 开始连续递增的顺序编号。所以可以用来分页。

阅读全文 »
04月
03
Spring

JdbcTemplate 笔记

发表于 2019-04-03 • 分类于 Spring

Methods dealing with static SQL (java.sql.Statement)

StatementCallback

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
@Override
public <T> T execute(StatementCallback<T> action) throws DataAccessException {
Assert.notNull(action, "Callback object must not be null");

Connection con = DataSourceUtils.getConnection(obtainDataSource());
Statement stmt = null;
try {
stmt = con.createStatement();
applyStatementSettings(stmt);
// 重写 doInStatement 方法时要加上查询和处理返回值的操作
T result = action.doInStatement(stmt);
handleWarnings(stmt);
return result;
}
catch (SQLException ex) {
// Release Connection early, to avoid potential connection pool deadlock
// in the case when the exception translator hasn't been initialized yet.
String sql = getSql(action);
JdbcUtils.closeStatement(stmt);
stmt = null;
DataSourceUtils.releaseConnection(con, getDataSource());
con = null;
throw translateException("StatementCallback", sql, ex);
}
finally {
JdbcUtils.closeStatement(stmt);
DataSourceUtils.releaseConnection(con, getDataSource());
}
}

上面的方法是基于 Statement 查询的基础方法,查询和修改等都是调用上面的方法。

阅读全文 »
04月
03
学习记录

VS Code 的使用

发表于 2019-04-03 • 分类于 学习记录

常用快捷键

  • 显示所有命令

    1
    Shift + Ctrl + P
  • 全局查找文件 / 打开最近访问的文件

    1
    Ctrl + P
  • 打开最近访问的文件

    1
    Ctrl + R
  • 在本文件中查找

    1
    Ctrl + F
  • 在本文件中替换

    1
    Ctrl + H
  • 格式化代码

    1
    Shift + Alt + F
阅读全文 »
04月
03
学习记录

IntelliJ IDEA 的使用

发表于 2019-04-03 • 分类于 学习记录

下载:IntelliJ IDEA Releases

常用快捷键

  • 全局查找文件

    1
    Double Shift
  • 打开最近访问的文件

    1
    Ctrl + E
  • 打开最近修改的文件

    1
    Shift + Ctrl + E
  • 回到上次打开的 Tab 页

    1
    Ctrl + Tab
  • 在本文件中查找

    1
    Ctrl + F
  • 在本文件中替换

    1
    Ctrl + R
  • 全文查找

    1
    Shift + Ctrl + F
  • 全文替换

    1
    Shift + Ctrl + R
阅读全文 »
03月
26
Git

Git 常用命令

发表于 2019-03-26 • 分类于 Git
  • clone 远程分支。

    1
    > git clone <remote-url>
  • 查看远程仓库。

    1
    2
    3
    4
    > git remote -v

    origin https://github.com/wuchao/wuchao.github.io.git (fetch)
    origin https://github.com/wuchao/wuchao.github.io.git (push)
  • 查看所有本地分支。

    1
    2
    3
    > git branch

    * master

    分支名前有 * 的。

  • 查看所有本地和远程分支。

    1
    2
    3
    4
    5
    6
    > git branch -a

    * master
    remotes/origin/HEAD -> origin/master
    remotes/origin/maintain
    remotes/origin/master
  • 初始化仓库。

    1
    > git init
  • (从当前分支上)新建分支。

    1
    > git branch 分支名
  • 切换分支。

    1
    > git checkout 分支名
阅读全文 »
03月
14
Linux

CentOS 的使用

发表于 2019-03-14 • 分类于 Linux
  • 查看 linux 内核信息

    1
    uname -a
  • 查看系统版本

    1
    cat  /etc/redhat-release
  • 查看源

    1
    2
    3
    yum repolist
    或
    ls /etc/yum.repos.d/
阅读全文 »
03月
14
问题记录

VirtualVM 启动系统镜像报 WinHvPlatform.dll not found

发表于 2019-03-14 • 分类于 问题记录

Windows 上安装 Docker 导致 VirtualVM 不能正常使用了。当启动系统镜像时报下面的错误提示:

1
2
3
4
5
6
7
8
9
The native API dll was not found (C:\Windows\system32\WinHvPlatform.dll) (VERR_NEM_NOT_AVAILABLE).
VT-x is not available (VERR_VMX_NO_VMX).

返回 代码:
E_FAIL (0x80004005)
组件:
ConsoleWrap
界面:
IConsole {872da645-4a9b-1727-bee2-5585105b9eed}

打开 WinHvPlatform.dll : Free Download 下载 WinHvPlatform.dll,并复制到 C:\Windows\system32\ 目录下面。

再次启动系统镜像,又报:

1
2
3
4
...
...
...
VT-x is not available (VERR_VMX_NO_VMX)

参考 VT-x is not available, but is enabled in BIOS 上面的回答,以系统管理员权限打开 cmd,然后执行下面命令:

1
dism.exe /Online /Disable-Feature:Microsoft-Hyper-V

重启系统。

阅读全文 »
03月
08
问题记录

JdbcTemplate ResultSetExtractor 执行报异常:No current row in the ResultSet

发表于 2019-03-08 • 分类于 问题记录

同一个查询,使用:

1
2
3
List<T> query(String sql, RowMapper<T> rowMapper, Object... args)

void query(String sql, Object[] args, RowCallbackHandler rch)

这两个方法可以执行成功,但是

1
T query(String sql, ResultSetExtractor<T> rse, Object... args)

执行时会报如下异常信息:

1
Caused by: java.sql.SQLException: No current row in the ResultSet.
阅读全文 »
03月
07
问题记录

Office 文档格式转换

发表于 2019-03-07 • 分类于 问题记录

之前用到 Office 的 word 转 pdf,doc 转 docx,试过了很多种方法,但是很多方法都有种种缺陷,或者不满足某种条件,其中用到 Aspose Words 和 Plutext-Enterprise 提供的 jar 包挺好用的,试用时没有一点问题,满足种种需求,但是都是商用付费的,最后看到了一种 word 转 pdf 的方法,就是在服务器上安装一个 LibreOffice 这个开源 Office 软件,然后调用一行命令就可以转换了,不仅速度快,而且转换质量高,然后用这种方法去将 doc 转成 docx 同样也是很好。

使用的是 Windows 服务器,Linux/Unix 服务器命令有所不同。

将 word(doc/docx) 转换成 pdf 的命令:

1
D:\Program Files\LibreOffice\program>soffice.bin --headless --invisible --convert-to pdf c:\Users\wu\xxx.doc --outdir c:\Users\wu

类似的可以将一种格式文档转换成另一种格式,只需要将 --convert-to 后的格式换成需要的目标格式即可。

阅读全文 »
1234…8
wuchao

72 日志
18 分类
Creative Commons

博客已萌萌哒运行(●'◡'●)ノ♥

© 2020 Keep Coding. 由 Hexo 强力驱动. Theme By Sagiri v0.0.4.

Made with by wuchao.