mybatis 连接presto查询(kudu)

添加maven依赖

        <dependency>
            <groupId>com.facebook.presto</groupId>
            <artifactId>presto-jdbc</artifactId>
            <version>0.208</version>
        </dependency>

 

 

1、配置tcbase.properties 文件

# kudu

dataSourceKudu.driverClassName=com.facebook.presto.jdbc.PrestoDriver

dataSourceKudu.url=jdbc:presto://xx.xx.xx.xx:8080/kudu/default  # 根据实际情况填写 

dataSourceKudu.username=root

 

2、配置连接文件

mybatis-kudu-spring.xml 文件

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

       xmlns:tx="http://www.springframework.org/schema/tx"

       xmlns:aop&
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 9
    评论
在Spring Boot中整合MyBatis-Plus实现Presto分页,可以按照以下步骤进行操作: 1. 首先,确保已经在项目的pom.xml文件中添加了MyBatis-Plus和Presto的依赖。 2. 在application.properties或application.yml文件中配置Presto连接信息,包括URL、用户名和密码等。 3. 创建一个Presto分页查询的方法,可以使用MyBatis-Plus提供的Page对象来实现分页功能。在该方法中,使用@Select注解定义SQL查询语句,并使用@Param注解指定方法参数。 4. 在方法中,使用Page对象的setRecords方法将查询结果设置到Page对象中,并使用Page对象的setTotal方法设置总记录数。 5. 在方法中,使用MyBatis-Plus的selectPage方法执行分页查询,并将Page对象作为参数传递给该方法。 6. 在Controller层调用Presto分页查询的方法,并将查询结果返回给前端。 下面是一个示例代码,演示了如何在Spring Boot中整合MyBatis-Plus实现Presto分页: ```java // 引入相关的包和注解 @Service public class PrestoService { @Autowired private PrestoMapper prestoMapper; public Page<PrestoEntity> getPrestoPage(int pageNum, int pageSize) { Page<PrestoEntity> page = new Page<>(pageNum, pageSize); List<PrestoEntity> records = prestoMapper.getPrestoPage(page); page.setRecords(records); return page; } } @Mapper public interface PrestoMapper { @Select("SELECT * FROM table_name") List<PrestoEntity> getPrestoPage(Page<PrestoEntity> page); } @RestController public class PrestoController { @Autowired private PrestoService prestoService; @GetMapping("/presto/page") public Page<PrestoEntity> getPrestoPage(@RequestParam int pageNum, @RequestParam int pageSize) { return prestoService.getPrestoPage(pageNum, pageSize); } } ``` 请注意,上述代码仅为示例,实际使用时需要根据具体的表名、字段名和查询条件进行修改。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 9
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值