支付宝红包
京东盲盒抽奖
幸运转盘
秒杀
自营热卖
支付宝红包

*******如何在项目中去扩展做题***********************

乱人心 1年前   阅读数 174 0

【今日推荐】:为什么一到面试就懵逼!>>>

1:在父亲项目上添加一个带maven的子模块

2: 步 

3: 

4: 

 

5:

添加maven pom.xml 依赖

<dependencies>
    <!-- https://mvnrepository.com/artifact/org.apache.hive/hive-jdbc -->

    <!-- https://mvnrepository.com/artifact/org.apache.hadoop/hadoop-client -->
    <dependency>
        <groupId>org.apache.hadoop</groupId>
        <artifactId>hadoop-common</artifactId>
        <version>2.7.2</version>
        <exclusions>
            <exclusion>
                <groupId>*</groupId>
                <artifactId>*</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

    <dependency>
        <groupId>org.apache.hadoop</groupId>
        <artifactId>hadoop-client</artifactId>
        <version>2.7.3</version>

        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.hive</groupId>
        <artifactId>hive-jdbc</artifactId>
        <version>1.2.2</version>
        <scope>provided</scope>

        <exclusions>
            <exclusion>
                <groupId>org.apache.hive</groupId>
                <artifactId>hive-shims</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.apache.hive</groupId>
                <artifactId>hive-serde</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.apache.hive</groupId>
                <artifactId>hive-metastore</artifactId>
            </exclusion>


        </exclusions>


    </dependency>






    <!-- https://mvnrepository.com/artifact/com.alibaba/fastjson -->
    <dependency>
        <groupId>com.alibaba</groupId>
        <artifactId>fastjson</artifactId>
        <version>1.2.47</version>
    </dependency>

</dependencies>

6: 在项目中添加 

这个依赖 

见如下

7:

9: 加上刚才那个类

 

10:

开始编程序

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

public class DayAddAyanlist {



    private static Connection getConnection() throws SQLException, ClassNotFoundException {
        Class.forName("org.apache.hive.jdbc.HiveDriver") ;
        //创建链接
        Connection connection = DriverManager.getConnection("jdbc:hive2://192.168.40.121:10000", "root", "123456");
        return connection;
    }


    private static void famgfa1() throws SQLException, ClassNotFoundException {
        Connection connection = getConnection();

        Statement statement = connection.createStatement();
        //查询结果
        statement.executeQuery("  select   count(distinct userdivceid ) from applogsdb.ext_startup_logs where createimems >= getdaybegin() and cccc< getdaybeging(1)");
        System.out.println( i);
        statement.close();
        connection.close();

    }


    public static void main(String[] args) {

    }

}

注意:本文归作者所有,未经作者允许,不得转载

全部评论: 0

    我有话说: