当前位置:网站首页>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
边栏推荐
- 小程序中实现付款功能
- 数据验证框架 Apache BVal 再使用
- [unity shader] insert pass to realize the X-ray perspective effect of model occlusion
- coming! Gaussdb (for Cassandra) new features appear
- GSAP animation library
- Do you really understand sticky bag and half bag? 3 minutes to understand it
- Hash, bitmap and bloom filter for mass data De duplication
- Thread pool and singleton mode and file operation
- Usage of PHP interview questions foreach ($arr as $value) and foreach ($arr as $value)
- [C language] string function
猜你喜欢
随机推荐
Five network IO models
Will domestic software testing be biased
线程池中的线程工厂
Wireshark分析抓包数据*.cap
我感觉被骗了,微信内测 “大小号” 功能,同一手机号可注册两个微信
Thread factory in thread pool
IP netns command (memo)
A few simple steps to teach you how to see the K-line diagram
Debian10 compile and install MySQL
清华、剑桥、UIC联合推出首个中文事实核查数据集:基于证据、涵盖医疗社会等多个领域
[C language] string function
Standard ACL and extended ACL
Disk storage chain B-tree and b+ tree
PTA 1101 B是A的多少倍
Three forms of multimedia technology commonly used in enterprise exhibition hall design
数据验证框架 Apache BVal 再使用
体总:安全有序恢复线下体育赛事,力争做到国内赛事应办尽办
Tsinghua, Cambridge and UIC jointly launched the first Chinese fact verification data set: evidence-based, covering many fields such as medical society
Rules for filling in volunteers for college entrance examination
AntiSamy:防 XSS 攻击的一种解决方案使用教程