当前位置:网站首页>Hutool - lightweight DB operation solution
Hutool - lightweight DB operation solution
2022-07-07 18:57:00 【Sheep yard】
The story background
occasionally , We don't have to use Hibernate、JPA、Mybatis Wait for a heavyweight framework to operate the database , Native JDBC That set is too cumbersome , Today I bring you a set Hutool Version of the database operation scheme
Maven
<!--mysql Database driven -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql.version}</version>
</dependency>Mode one
DataSource ds = new SimpleDataSource("jdbc:mysql://localhost:3306/lux?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai", "root", "123456");
Db db = DbUtil.use(ds);
List<TagPO> rs = db.query("select * from t_as_tag", TagPO.class);Mode two
## db.setting file
url = jdbc:mysql://localhost:3306/test
user = root
pass = 123456
## Optional configuration
# Whether to display the executed in the log SQL
showSql = true
# Whether to format the displayed SQL
formatSql = false
# Whether or not shown SQL Parameters
showParams = true
# Print SQL Log level of , Default debug, It can be info、warn、error
sqlLevel = debugList<Entity> result = Db.use().query("select * from user where age < ?", 3);Reference documents
边栏推荐
猜你喜欢

卖空、加印、保库存,东方甄选居然一个月在抖音卖了266万单书

静态路由配置
![学习open62541 --- [67] 添加自定义Enum并显示名字](/img/98/e5e25af90b3f98c2be11d7d21e5ea6.png)
学习open62541 --- [67] 添加自定义Enum并显示名字

Hash, bitmap and bloom filter for mass data De duplication

Will low code help enterprises' digital transformation make programmers unemployed?

【Unity Shader】插入Pass实现模型遮挡X光透视效果

Introduction de l'API commune de programmation de socket et mise en œuvre de socket, select, Poll et epoll

RIP和OSPF的区别和配置命令

Static routing configuration

清华、剑桥、UIC联合推出首个中文事实核查数据集:基于证据、涵盖医疗社会等多个领域
随机推荐
The live broadcast reservation channel is open! Unlock the secret of fast launching of audio and video applications
Nat address translation
持续测试(CT)实战经验分享
云安全日报220707:思科Expressway系列和网真视频通信服务器发现远程攻击漏洞,需要尽快升级
A few simple steps to teach you how to see the K-line diagram
标准ACL与扩展ACL
Disk storage chain B-tree and b+ tree
PIP related commands
[paddleseg source code reading] add boundary IOU calculation in paddleseg validation (1) -- val.py file details tips
Redis cluster and expansion
[sword finger offer] 59 - I. maximum value of sliding window
gsap动画库
Embedded interview questions (algorithm part)
Classification of regression tests
Redis
如何选择合适的自动化测试工具?
Redis
Reject policy of thread pool
[C language] string function
线程池中的线程工厂