1. import java.sql.DriverManager
  2. import org.apache.hive.jdbc.HiveDriver
  3. object HiveTest {
  4. def main(args: Array[String]): Unit = {
  5. val driverName =
  6. "org.apache.hive.jdbc.HiveDriver"
  7. classOf[HiveDriver]
  8. val con = DriverManager.getConnection(
  9. "jdbc:hive2://MVP-HADOOP29:10002/hive", "hadoop", "hadoop");
  10. val stmt = con.createStatement
  11. val sql = "select * from uxin_car_info_origin where dt='2019-05-01' limit 1"
  12. System.out.println("Running: " + sql)
  13. val res = stmt.executeQuery(sql)
  14. if (res.next()) {
  15. System.out.println(res.getString(1))
  16. }
  17. }
  18. }
文档更新时间: 2019-07-25 11:53   作者:admin