0

Ubuntu 16.04.1 LTS
hadoop 3.3.1
Hive 2.3.9

我有一个java文件:

public class HiveCreateDb {
    private static String driverName = "org.apache.hive.jdbc.HiveDriver";
    public static void main(String[] args) throws SQLException {
        // Register driver and create driver instance
        try {
            Class.forName(driverName);
        } catch (ClassNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            System.exit(1);
        }
        // get connection
        Connection con = DriverManager.getConnection("jdbc:hive://localhost:10000/default", "", "");
        Statement stmt = con.createStatement();
        stmt.executeQuery("CREATE DATABASE userdb");
        System.out.println("Database userdb created successfully.");
        con.close();
    }
}

我把这个java文件放在ubuntu文件夹中,然后运行

javac HiveCreateDb.java 
HiveCreateDb.java:14: error: unreported exception ClassNotFoundException; must be caught or declared to be thrown
        Class.forName(driverName);
                     ^
1 error

我已经下载了 hive-jdbc-3.1.2.jar,我应该把这个 jar 放在哪里?

4

1 回答 1

0

javac -classpath jars/hive-jdbc-2.3.9.jar 源/HiveCreateDb.java

于 2021-07-08T07:34:54.437 回答