title: Hive - connection to Java via JDBC
body: <p>I have a problem. I can't connect my simple java application to my db. I think it's a problem with drivers.</p>
  
  <p>Here are hive logs, when I'm starting it:
  <a href="https://i.stack.imgur.com/dsSig.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dsSig.png" alt=""></a>
  My simple code:</p>
  
  <pre><code>package bazahive;
  
  import java.sql.Connection;
  import java.sql.DriverManager;
  import java.sql.SQLException;
  import java.sql.Statement;
  import java.sql.ResultSet;
  import java.util.Scanner;
  
  public class baza{
      private static String driverName = "org.apache.hive.jdbc.HiveDriver";
      public static void main(String[] args) throws SQLException {
          try {
                Class.forName(driverName);
              } catch (ClassNotFoundException e) {
                e.printStackTrace();
                System.exit(1);
              }
          Connection con = DriverManager.getConnection("jdbc:hive2://localhost:50070/przychodnia", "", "");
          Scanner odczyt = new Scanner(System.in);
          System.out.println("Wybierz");
          System.out.println("0 aby dodać do istniejącej tabeli wiersz");
          System.out.println("1 aby usunąć z istniejącej tabeli wiersz");
          String x = odczyt.nextLine();
          switch(x){
              case("0"):
                  Statement stmt = con.createStatement();
                  String SQL = "SELECT ai(),* FROM pacjenci";
                  ResultSet rs = stmt.executeQuery(SQL);
  
                  while (rs.next()){
                      int ai = rs.getInt("ai()");
                      String imie = rs.getString("imie");
                      String p = ai + " " + imie;
                      System.out.println(p);
  
          }
  
      }
      }
  }
  </code></pre>
  
  <p>Errors:</p>
  
  <pre><code>ERROR StatusLogger Unrecognized format specifier [d]
  ERROR StatusLogger Unrecognized conversion specifier [d] starting at position 16 in conversion pattern.
  ERROR StatusLogger Unrecognized format specifier [thread]
  ERROR StatusLogger Unrecognized conversion specifier [thread] starting at position 25 in conversion pattern.
  ERROR StatusLogger Unrecognized format specifier [level]
  ERROR StatusLogger Unrecognized conversion specifier [level] starting at position 35 in conversion pattern.
  ERROR StatusLogger Unrecognized format specifier [logger]
  ERROR StatusLogger Unrecognized conversion specifier [logger] starting at position 47 in conversion pattern.
  ERROR StatusLogger Unrecognized format specifier [msg]
  ERROR StatusLogger Unrecognized conversion specifier [msg] starting at position 54 in conversion pattern.
  ERROR StatusLogger Unrecognized format specifier [n]
  ERROR StatusLogger Unrecognized conversion specifier [n] starting at position 56 in conversion pattern.
  ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console.
  ERROR StatusLogger Unrecognized format specifier [d]
  ERROR StatusLogger Unrecognized conversion specifier [d] starting at position 16 in conversion pattern.
  ERROR StatusLogger Unrecognized format specifier [thread]
  ERROR StatusLogger Unrecognized conversion specifier [thread] starting at position 25 in conversion pattern.
  ERROR StatusLogger Unrecognized format specifier [level]
  ERROR StatusLogger Unrecognized conversion specifier [level] starting at position 35 in conversion pattern.
  ERROR StatusLogger Unrecognized format specifier [logger]
  ERROR StatusLogger Unrecognized conversion specifier [logger] starting at position 47 in conversion pattern.
  ERROR StatusLogger Unrecognized format specifier [msg]
  ERROR StatusLogger Unrecognized conversion specifier [msg] starting at position 54 in conversion pattern.
  ERROR StatusLogger Unrecognized format specifier [n]
  ERROR StatusLogger Unrecognized conversion specifier [n] starting at position 56 in conversion pattern.
  Exception in thread "main" java.sql.SQLException: Could not open client transport with JDBC Uri: jdbc:hive2://localhost:50070/przychodnia: Invalid status 72
      at org.apache.hive.jdbc.HiveConnection.openTransport(HiveConnection.java:219)
      at org.apache.hive.jdbc.HiveConnection.&lt;init&gt;(HiveConnection.java:157)
      at org.apache.hive.jdbc.HiveDriver.connect(HiveDriver.java:107)
      at java.sql.DriverManager.getConnection(Unknown Source)
      at java.sql.DriverManager.getConnection(Unknown Source)
      at bazahive.baza.main(baza.java:19)
  Caused by: org.apache.thrift.transport.TTransportException: Invalid status 72
      at org.apache.thrift.transport.TSaslTransport.sendAndThrowMessage(TSaslTransport.java:232)
      at org.apache.thrift.transport.TSaslTransport.receiveSaslMessage(TSaslTransport.java:184)
      at org.apache.thrift.transport.TSaslTransport.open(TSaslTransport.java:307)
      at org.apache.thrift.transport.TSaslClientTransport.open(TSaslClientTransport.java:37)
      at org.apache.hive.jdbc.HiveConnection.openTransport(HiveConnection.java:195)
      ... 5 more
  </code></pre>
  
  <p>I added two jars into my project:</p>
  
  <pre><code>hadoop-common-2.3.0.jar
  hive-jdbc-2.1.0-standalone.jar
  </code></pre>
  
  <p>I'm using derby from java.</p>
  
  <p>EDIT:</p>
  
  <pre><code>ERROR StatusLogger Unrecognized format specifier [d]
  ERROR StatusLogger Unrecognized conversion specifier [d] starting at position 16 in conversion pattern.
  ERROR StatusLogger Unrecognized format specifier [thread]
  ERROR StatusLogger Unrecognized conversion specifier [thread] starting at position 25 in conversion pattern.
  ERROR StatusLogger Unrecognized format specifier [level]
  ERROR StatusLogger Unrecognized conversion specifier [level] starting at position 35 in conversion pattern.
  ERROR StatusLogger Unrecognized format specifier [logger]
  ERROR StatusLogger Unrecognized conversion specifier [logger] starting at position 47 in conversion pattern.
  ERROR StatusLogger Unrecognized format specifier [msg]
  ERROR StatusLogger Unrecognized conversion specifier [msg] starting at position 54 in conversion pattern.
  ERROR StatusLogger Unrecognized format specifier [n]
  ERROR StatusLogger Unrecognized conversion specifier [n] starting at position 56 in conversion pattern.
  ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console.
  ERROR StatusLogger Unrecognized format specifier [d]
  ERROR StatusLogger Unrecognized conversion specifier [d] starting at position 16 in conversion pattern.
  ERROR StatusLogger Unrecognized format specifier [thread]
  ERROR StatusLogger Unrecognized conversion specifier [thread] starting at position 25 in conversion pattern.
  ERROR StatusLogger Unrecognized format specifier [level]
  ERROR StatusLogger Unrecognized conversion specifier [level] starting at position 35 in conversion pattern.
  ERROR StatusLogger Unrecognized format specifier [logger]
  ERROR StatusLogger Unrecognized conversion specifier [logger] starting at position 47 in conversion pattern.
  ERROR StatusLogger Unrecognized format specifier [msg]
  ERROR StatusLogger Unrecognized conversion specifier [msg] starting at position 54 in conversion pattern.
  ERROR StatusLogger Unrecognized format specifier [n]
  ERROR StatusLogger Unrecognized conversion specifier [n] starting at position 56 in conversion pattern.
  Exception in thread "main" org.apache.commons.logging.LogConfigurationException: java.lang.ClassNotFoundException: org.apache.commons.logging.impl.LogFactoryImpl (Caused by java.lang.ClassNotFoundException: org.apache.commons.logging.impl.LogFactoryImpl)
      at org.apache.commons.logging.LogFactory.createFactory(LogFactory.java:1158)
      at org.apache.commons.logging.LogFactory$2.run(LogFactory.java:960)
      at java.security.AccessController.doPrivileged(Native Method)
      at org.apache.commons.logging.LogFactory.newFactory(LogFactory.java:957)
      at org.apache.commons.logging.LogFactory.getFactory(LogFactory.java:624)
      at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:655)
      at org.apache.http.conn.ssl.DefaultHostnameVerifier.&lt;init&gt;(DefaultHostnameVerifier.java:69)
      at org.apache.http.impl.client.HttpClientBuilder.build(HttpClientBuilder.java:901)
      at org.apache.hive.jdbc.HiveConnection.getHttpClient(HiveConnection.java:402)
      at org.apache.hive.jdbc.HiveConnection.createHttpTransport(HiveConnection.java:250)
      at org.apache.hive.jdbc.HiveConnection.openTransport(HiveConnection.java:193)
      at org.apache.hive.jdbc.HiveConnection.&lt;init&gt;(HiveConnection.java:157)
      at org.apache.hive.jdbc.HiveDriver.connect(HiveDriver.java:107)
      at java.sql.DriverManager.getConnection(Unknown Source)
      at java.sql.DriverManager.getConnection(Unknown Source)
      at hive.main(hive.java:17)
  Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.impl.LogFactoryImpl
      at java.net.URLClassLoader.findClass(Unknown Source)
      at java.lang.ClassLoader.loadClass(Unknown Source)
      at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
      at java.lang.ClassLoader.loadClass(Unknown Source)
      at org.apache.commons.logging.LogFactory.createFactory(LogFactory.java:1020)
      ... 15 more
  </code></pre>
  
  <p>EDIT2:
  <a href="https://i.stack.imgur.com/WPmen.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WPmen.png" alt="enter image description here"></a></p>
  
  <p>Translating: There was a connection refused because they not found the database.</p>