package util.sqlparse.visitor.hivetdh;

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

public class TestJdbc {
   public static void main(String[] args) throws InterruptedException, SQLException, ClassNotFoundException {
      Connection connection = connection();
      test1(connection);
   }

   private static void test1(Connection connection) throws ClassNotFoundException, SQLException {
      Statement statement = connection.createStatement();
      statement.execute("SELECT * FROM ccc");
   }

   private static void test2(Connection connection) throws ClassNotFoundException, SQLException {
      Statement statement = connection.createStatement();
      PreparedStatement prestmt = connection.prepareStatement("SELECT * FROM ccc limit ?");
      prestmt.setInt(1, 1);
      prestmt.executeQuery();
   }

   private static Connection connection() throws SQLException, ClassNotFoundException {
      Class.forName("org.apache.hive.jdbc.HiveDriver");
      String url = "jdbc:hive2://10.11.120.15:10000/default";
      Connection connection = DriverManager.getConnection(url, "admin", "admin");
      return connection;
   }
}
