RJDBC - 无法使用 JDBC Uri 打开客户端传输
RJDBC - Could not open client transport with JDBC Uri
我正在尝试从 RJDBC 连接到我的 Biginsights Enterprise 集群:
hiveconnection <- dbConnect(drv,
"jdbc:hive2://xxxxx:10001/default",
"xxxxx",
"xxxxx",
ssl="true",
sslTrustStore="mytruststore.jks",
trustStorePassword="xxxxx",
hive.server2.transport.mode="http",
hive.server2.thrift.http.path="gateway/default/hive
)
但是,我遇到了问题:
Could not open client transport with JDBC Uri
这对我有用:
username = 'changeme'
password = 'changeme'
# change this to your hostname
url = 'jdbc:hive2://bi4c-xxxx-master-3.bi.services.bluemix.net:10000/default;ssl=true;sslTrustStore=/change/to/yourpath/to/truststore.jks;trustStorePassword=mypassword;'
library(rJava)
library(RJDBC)
hive.class.path = list.files(path=c('/change/to/yourpath/to/build/hivedrivers/'), pattern="jar", full.names=T);
.jinit(classpath=hive.class.path,parameters="")
drv <- JDBC("org.apache.hive.jdbc.HiveDriver","hive-jdbc-2.0.0.jar",identifier.quote="`")
conn <- dbConnect(drv,url,username,password)
show_databases <- dbGetQuery(conn, "show databases")
print(show_databases)
设置步骤
我使用 gradle 将所有配置单元 jdbc 依赖项下载到一个文件夹中。我接下来创建了一个 build.gradle
文件:
repositories {
mavenCentral()
}
configurations {
drivers
}
dependencies {
drivers "org.apache.hive:hive-jdbc:2.0.0"
}
task CopyDrivers(type: Copy) {
from configurations.drivers
into "$buildDir/hivedrivers"
}
然后在终端 window 我切换到我的 build.gradle 文件的目录,我执行了:
$ gradle CopyDrivers
我创建了信任库:
$ BI_HOST=bi4c-xxxxx-master-3.bi.services.bluemix.net
$ openssl s_client -showcerts -connect $BI_HOST:9443 < /dev/null | openssl x509 -outform PEM > certificate
$ rm -f truststore.jks
$ keytool -import -trustcacerts -alias biginsights -file certificate -keystore truststore.jks -storepass mypassword -noprompt
我正在尝试从 RJDBC 连接到我的 Biginsights Enterprise 集群:
hiveconnection <- dbConnect(drv,
"jdbc:hive2://xxxxx:10001/default",
"xxxxx",
"xxxxx",
ssl="true",
sslTrustStore="mytruststore.jks",
trustStorePassword="xxxxx",
hive.server2.transport.mode="http",
hive.server2.thrift.http.path="gateway/default/hive
)
但是,我遇到了问题:
Could not open client transport with JDBC Uri
这对我有用:
username = 'changeme'
password = 'changeme'
# change this to your hostname
url = 'jdbc:hive2://bi4c-xxxx-master-3.bi.services.bluemix.net:10000/default;ssl=true;sslTrustStore=/change/to/yourpath/to/truststore.jks;trustStorePassword=mypassword;'
library(rJava)
library(RJDBC)
hive.class.path = list.files(path=c('/change/to/yourpath/to/build/hivedrivers/'), pattern="jar", full.names=T);
.jinit(classpath=hive.class.path,parameters="")
drv <- JDBC("org.apache.hive.jdbc.HiveDriver","hive-jdbc-2.0.0.jar",identifier.quote="`")
conn <- dbConnect(drv,url,username,password)
show_databases <- dbGetQuery(conn, "show databases")
print(show_databases)
设置步骤
我使用 gradle 将所有配置单元 jdbc 依赖项下载到一个文件夹中。我接下来创建了一个 build.gradle
文件:
repositories {
mavenCentral()
}
configurations {
drivers
}
dependencies {
drivers "org.apache.hive:hive-jdbc:2.0.0"
}
task CopyDrivers(type: Copy) {
from configurations.drivers
into "$buildDir/hivedrivers"
}
然后在终端 window 我切换到我的 build.gradle 文件的目录,我执行了:
$ gradle CopyDrivers
我创建了信任库:
$ BI_HOST=bi4c-xxxxx-master-3.bi.services.bluemix.net
$ openssl s_client -showcerts -connect $BI_HOST:9443 < /dev/null | openssl x509 -outform PEM > certificate
$ rm -f truststore.jks
$ keytool -import -trustcacerts -alias biginsights -file certificate -keystore truststore.jks -storepass mypassword -noprompt