当前位置:网站首页>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 = debug
List<Entity> result = Db.use().query("select * from user where age < ?", 3);
Reference documents
边栏推荐
- 线程池中的线程工厂
- PHP面试题 foreach($arr as &$value)与foreach($arr as $value)的用法
- coming! Gaussdb (for Cassandra) new features appear
- nest.js入门之 database
- gsap动画库
- Charles+drony的APP抓包
- Cloud security daily 220707: Cisco Expressway series and telepresence video communication server have found remote attack vulnerabilities and need to be upgraded as soon as possible
- 静态路由配置
- Redis的发布与订阅
- Do you really understand sticky bag and half bag? 3 minutes to understand it
猜你喜欢
Redis集群与扩展
Backup Alibaba cloud instance OSS browser
Some key points in the analysis of spot Silver
嵌入式C语言程序调试和宏使用的技巧
标准ACL与扩展ACL
[Tawang methodology] Tawang 3W consumption strategy - U & a research method
gsap动画库
小试牛刀之NunJucks模板引擎
卖空、加印、保库存,东方甄选居然一个月在抖音卖了266万单书
Reinforcement learning - learning notes 8 | Q-learning
随机推荐
The highest level of anonymity in C language
嵌入式面试题(算法部分)
Reuse of data validation framework Apache bval
Comparison and selection of kubernetes Devops CD Tools
来了!GaussDB(for Cassandra)新特性亮相
Performance test process and plan
Download, installation and development environment construction of "harmonyos" deveco
五种网络IO模型
Standard ACL and extended ACL
Kubernetes DevOps CD工具对比选型
[sword finger offer] 59 - I. maximum value of sliding window
【塔望方法论】塔望3W消费战略 - U&A研究法
低代码助力企业数字化转型会让程序员失业?
Thread pool and singleton mode and file operation
socket編程之常用api介紹與socket、select、poll、epoll高並發服務器模型代碼實現
[unity shader] insert pass to realize the X-ray perspective effect of model occlusion
Idea completely uninstalls installation and configuration notes
二叉树的基本概念和性质
单臂路由和三层交换的简单配置
[论文分享] Where’s Crypto?