Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • JDBC connection to Google BigQuery Database

    Does anyone here connect to BQ using JDBC successfully? I've been trying to make this work, as I did with ODBC, but with no luck.

    I have JRE installed:

    Code:
    $ java -version
    java version "10" 2018-03-20
    Java(TM) SE Runtime Environment 18.3 (build 10+46)
    Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10+46, mixed mode)
    I have the Magnitude Simba JDBC release 1.2.16.1020, which is JDBC 4.2-compatible from here.

    I unzipped that into ~/ado/simba_jdbc, which is on my ado-path:

    Code:
    . adopath
      [1]  (BASE)      "/Applications/Stata/ado/base/"
      [2]  (SITE)      "/Applications/Stata/ado/site/"
      [3]              "."
      [4]  (PERSONAL)  "/Users/dimitriy/ado/"
      [5]  (PLUS)      "/Users/dimitriy/Library/Application Support/Stata/ado/plus/"
      [6]  (OLDPLACE)  "~/ado/"
      [7]              "~/ado/simba_jdbc"

    I am able to jdbc connect (or there are no errors):

    Code:
    . #delimit cr
    delimiter now cr
    . set debug on
    
    . local jar "GoogleBigQueryJDBC42.jar"
    
    . local driverclass "com.simba.googlebigquery.jdbc.Driver"
    
    . local url "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;ProjectId=XXXX;OAuthType=YYY;OAuthRefreshToken=ZZZ;"
    
    . local user "AAAA"
    
    . local pass "BBBB"
    
    . jdbc connect,  jar(`"`jar'"') driverclass("`driverclass'") url("`url'") user("`user'") password("`pass'")
    Classpaths:
        file:/Applications/Stata/ado/base/jar/libstata-plugin.jar
    Classpaths (add):
        file:/Users/dimitriy/ado/simba_jdbc/GoogleBigQueryJDBC42.jar
        file:/Applications/Stata/ado/base/jar/libstata-plugin.jar
    Classpaths:
        file:/Applications/Stata/ado/base/jar/libstata-plugin.jar
    But then I am not able to see the tables:

    Code:
    . jdbc showtable
    Classpaths:
        file:/Applications/Stata/ado/base/jar/libstata-plugin.jar
    java.lang.ClassNotFoundException: com.google.auth.http.HttpTransportFactory
            at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:471)
            at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:589)
            at java.base/java.net.FactoryURLClassLoader.loadClass(URLClassLoader.java:899)
            at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
            at com.simba.googlebigquery.googlebigquery.core.BQConnection.connect(Unknown Source)
            at com.simba.googlebigquery.jdbc.common.BaseConnectionFactory.doConnect(Unknown Source)
            at com.simba.googlebigquery.jdbc.common.AbstractDriver.connect(Unknown Source)
            at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:677)
            at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:189)
            at com.stata.plugins.jdbc.StJdbc.getConnection(StJdbc.java:168)
            at com.stata.plugins.jdbc.StJdbc.showTables(StJdbc.java:1796)
            at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
            at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
            at java.base/java.lang.reflect.Method.invoke(Method.java:566)
            at com.stata.Javacall.load(Javacall.java:270)
            at com.stata.Javacall.load(Javacall.java:92)
    r(5100);
    Any idea what's going wrong?

  • #2
    Did the Big Query JDBC driver zip file you download have one .jar file or multiple .jar files?

    Comment


    • #3
      There were multiple jars. Do I need to put all of them, comma-separated, in the jar local?

      Update: When I do that, Stata crashes.
      Last edited by Dimitriy V. Masterov; 23 Jun 2021, 11:38.

      Comment


      • #4
        Please contact [email protected] so that we can assist you further.

        Comment


        • #5
          Dimitriy problem occurs because Google's BigQuery JDBC driver requires multiple jar files to work. In the update that went out today, July 13, 2021, there is a new option for jdbc connect, jarpath(DirectoryName), that will address this problem. If your JDBC driver requires multiple jar files to work, unzip the jar file into a new directory and specify this new path in your jdbc connect command. For example,

          Code:
          jdbc connect, jarpath("C:\users\kevin\Desktop\jdbc\simba")...

          Comment

          Working...
          X