zoukankan      html  css  js  c++  java
  • springboot 整和 presto

    参考原文:https://blog.csdn.net/Sunhighlight/article/details/89044374

    依赖:

     
    <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.1.16.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
    </parent>


    <dependency>

    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-jdbc</artifactId>
    </dependency>
       <dependency>
          <groupId>com.facebook.presto</groupId>
          <artifactId>presto-jdbc</artifactId>
          <version>0.203</version>
        </dependency>

    配置application.yml文件

     datasource:
        presto:
          name: presto
          type: org.apache.tomcat.jdbc.pool.DataSource
          driver-class-name: com.facebook.presto.jdbc.PrestoDriver
          url: jdbc:presto://192.168.18.129:8881/test/sea
          username: root

    注意:
    (1)本项目其他数据源使用的是阿里巴巴druid数据库连接池,但是该连接池不支持PrestoDB,如果使用会爆出:java.lang.IllegalStateException: dbType not support错误,故我们用org.apache.tomcat.jdbc.pool.DataSource连接池

    3.3创建数据源配置类

    @Configuration
    public class GlobalDataSourceConfiguration {
    
      private static Logger LOG = LoggerFactory.getLogger(GlobalDataSourceConfiguration.class);
    
      @Bean(name = "prestoDataSource")
      @ConfigurationProperties(prefix = "datasource.presto")
      public DataSource prestoDataSource() {
        LOG.info("-------------------- presto init ---------------------");
        return DataSourceBuilder.create().build();
      }
    
      @Bean(name = "prestoTemplate")
      public JdbcTemplate prestoJdbcTemplate(@Qualifier("prestoDataSource") DataSource dataSource) {
        return new JdbcTemplate(dataSource);
      }
    
    }

    4.3使用prestoDB直接执行SQL

       @Autowired
       @Qualifier("prestoTemplate")
        private JdbcTemplate prestoTemplate;
    
       List<Map<String, Object>> result =  prestoTemplate.queryForList("sql");
  • 相关阅读:
    PHP中如何防止跨域调用接口
    301、404、200、304、500HTTP状态
    多表联合查询
    put方式提交上传图片
    获取样式属性getComputed,currentStyle
    AjaxPro异步加载服务器的时间
    在 ASP.NET 中执行 URL 重写
    ASP.NET 的前世今生 之 .NET Framework
    asp.net 读写 XML 转载自 yiki'space
    可爱的人人
  • 原文地址:https://www.cnblogs.com/lshan/p/13690316.html
Copyright © 2011-2022 走看看