IBM Data Science Experience (DSX): Using ibmdbR on RStudio

306 views Asked by At

I’ve created a connection to Db2 Warehouse on Cloud: dashDB for Analytics-t1 / Database: BLUDB. I’ve given ‘dashdb connect’ as the connection name.

Then I've selected Tools / RStudio. In RStudio, I've run the following lines. The error message below.

Code snippet:

library(ibmdbR)
con <- idaConnect('BLUDB','','')
#Close the connection
idaClose(con)

Output:

con <- idaConnect('BLUDB','','')
Warning messages:
1: In RODBC::odbcDriverConnect("DSN=BLUDB", believeNRows = FALSE) :  [RODBC] ERROR: state 08001, code -30082, message [unixODBC][IBM][CLI Driver] SQL30082N  Security processing failed with reason "17" ("UNSUPPORTED FUNCTION").  SQLSTATE=08001
2: In RODBC::odbcDriverConnect("DSN=BLUDB", believeNRows = FALSE) :  ODBC connection failed
1

There are 1 answers

0
ptitzler On

Your code snippet will only work as is if you run it in the RStudio from the DB2 Warehouse console. If you launch RStudio within DSX you need to configure connectivity. The following worked for me:

install.packages("ibmdbR")
library(ibmdbR)
dsn_driver <- "BLUDB"
dsn_database <- "BLUDB"
dsn_hostname <- "..."
dsn_port <- "50000"
dsn_protocol <- "TCPIP"
dsn_uid <- "..."
dsn_pwd <- "..."
con_path <- paste(dsn_driver,";DATABASE=",dsn_database,";HOSTNAME=",dsn_hostname,";PORT=",dsn_port,";PROTOCOL=",dsn_protocol,";UID=",dsn_uid,";PWD=",dsn_pwd,sep="")
ch <-idaConnect(con_path)
idaInit(ch)
idaShowTables()

Replace "..." with your credentials and you should be good to go. I followed the instructions from the video named "Connect to dashDB in RStudio" on this page: https://datascience.ibm.com/docs/content/analyze-data/rstudio-overview.html and found the following documentation: https://datascience.ibm.com/blog/dashdb-r-dsx/