zoukankan      html  css  js  c++  java
  • hutool工具包学习

    2021-09-12

    数据库操作

            DbConfig conf = new DbConfig("jdbc:mysql://localhost:3306/test?useUnicode=true", "root", "123456");
            conf.setMaxActive(1);
            PooledDataSource ds = new PooledDataSource(conf);
            Connection c = ds.getConnection();
            SqlConnRunner r = SqlConnRunner.create(ds);
            Entity entity = new Entity("tb_cus");
            long l = r.count(c,  entity);
            System.out.println(l);

    2021-09-24

    连表查询

            DbConfig conf = new DbConfig("jdbc:mysql://localhost:3306/test?useUnicode=true", "root", "123456");
            conf.setMaxActive(1);
            PooledDataSource ds = new PooledDataSource(conf);
            Connection c = ds.getConnection();
            Db db = new Db(ds);
            List<Entity> ls = db.query("select res_code from tb_cus where res_code = ?", "11001010000300");
            System.out.println(ls.size());
            List<vo> v = db.query("select a.res_code, a.res_value, b.S_VIDEO_NAME as name from tb_cus a left join tc_video_info b on (a.res_code = b.S_VIDEO_CODE) where res_code = ?;", vo.class, "11001010000300");
            System.out.println(v.size());

     redis查询

            Setting setting = new Setting();
            setting.set("port", "16386");
            RedisDS rds = new RedisDS(setting, null);
            String t = rds.getStr("username");
            System.out.println(t);

    需要依赖:

            <dependency>
                <groupId>org.apache.commons</groupId>
                <artifactId>commons-pool2</artifactId>
                <version>2.4.2</version>
            </dependency>
            <dependency>
                <groupId>redis.clients</groupId>
                <artifactId>jedis</artifactId>
                <version>3.1.0</version>
            </dependency>

    2021-09-26

    在获取ID的时候,明明是字符串, 通过.getStr("SID"),返回的是[48, 48, 49, 67, 80, 108, 89, 52, 83, 85, 55, 57, 50, 53, 51, 51]

    然后通过get("SID").getClass().getName(),返回是[B,这样就很明显了,这个是Byte的数组,如果想转成字符串,

    只能是 new String((byte[])ls.get(0).get("SID"))

    第二天对比才知道,原来数据库里SID申明的是varbinary

    2021-10-09

    配置useUnicode=true时

    查某一个字段=xxx中文时,结果为空,实际用数据库查,数据存在。

    后来配置改成useUnicode=true&characterEncoding=UTF-8

    可以正常查结果了。

    2021-10-16

    jdk7 版本(v4.6.10)的 cn.hutool.core.util.PinyinUtil 已不能用了,有些中文转不了,比如 妃

    要用更高版本(jdk8+ v5+)的cn.hutool.extra.pinyin.PinyinUtil

  • 相关阅读:
    CobaltStrike上线Linux主机(CrossC2)
    Active-Directory活动目录备忘录
    CVE-2020-5902 F5 BIG-IP 远程代码执行漏洞复现
    SSTI-服务端模板注入漏洞
    powershell代码混淆绕过
    绕过PowerShell执行策略方法
    "dpkg: 处理归档 /var/cache/apt/archives/libjs-jquery_3.5.1+dfsg-4_all.deb (--unpack)时出错"的解决方法
    firda安装和使用
    内网渗透-跨域攻击
    Web-Security-Learning
  • 原文地址:https://www.cnblogs.com/angelshelter/p/15260415.html
Copyright © 2011-2022 走看看