Cannot connect R to DB2 - r

I want to connect R 3.2.3 to DB2. I tried this code :
library(RJDBC)
jcc = JDBC("com.ibm.db2.jcc.DB2Driver","c:/installed/sqllib/java/db2jcc4.jar")
I get this error :
Error: could not find function "JDBC"
Any Ideas ?

Tantaoui, I suggest you take a look at ibmdbR, which is a dedicated R data frame API to DB2 and dashDB data: https://cran.r-project.org/web/packages/ibmdbR/ibmdbR.pdf

Related

Writing data rom R to AWS Redshift db directly

Is there a way to write large datasets from R studio to AWS Redshift db directly? I used the following solution that I got online. but it throws error -unused argument: tablename=".."
install.packages('devtools')
devtools::install_github("RcppCore/Rcpp")
devtools::install_github("rstats-db/DBI")
devtools::install_github("rstats-db/RPostgres")
install.packages("aws.s3", repos = c(getOption("repos"), "http://cloudyr.github.io/drat"))
devtools::install_github("sicarul/redshiftTools")
library("aws.s3") library(RPostgres) library(redshiftTools)
pconn_r <- dbConnect(RPostgres::Postgres(), dbname="db",
host='xyz.db.amazon.com', port='1234',
user='user', password='pwd',sslmode='require')
rs_replace_table(tst, dbcon=pconn_r, tableName='abc', bucket="pqr")
Please help!
You can look that library: redshift-r
Or connect throught RJDBC: RJDBC

I am getting a class not found error when I try to connect R with AWS Redshift

I am trying to connect R with redshift using the JDBC template they provide on their website.
I got the most updated version of the redshift jdbc and pulled JDBC() and it's not working.
install.packages("RJDBC",dep=TRUE)
library(RJDBC)
download.file('https://s3.amazonaws.com/redshift-downloads/drivers/RedshiftJDBC42-1.2.10.1009.jar','RedshiftJDBC42-1.2.10.1009.jar')
driver_redshift <- JDBC("com.amazon.redshift.jdbc42.Driver",
"RedshiftJDBC41-1.1.9.1009.jar", identifier.quote="`")
I am getting an error that says Error in .jfindClass(as.character(driverClass)[1]) : class not found
Try to download the driver with binary mode:
download.file('https://s3.amazonaws.com/redshift-downloads/drivers/RedshiftJDBC42-1.2.10.1009.jar','RedshiftJDBC42-1.2.10.1009.jar', mode="wb");
Then make sure that you're referring the correct jar:
driver <- JDBC("com.amazon.redshift.jdbc42.Driver", "RedshiftJDBC42-1.2.10.1009.jar", identifier.quote="`")

how to read data from Cassandra (DBeaver) to R

I am using Cassandra CQL- system in DBeaver database tool. I want to connect this cassandra to R to read data. Unfortunately the connection takes more time (i waited for more than 2 hours) with RCassandra package. but it does not seem to get connected at all and still loading. Does anyone has any idea on this?
the code as follows:
library(RCassandra)
rc <- RC.connect(host ="********", port = 9042)
RC.login(rc, username = "*****", password = "******")
after this step RC.login, it is still loading for more than 2 hours.
I have also tried using RJDBC package like posted here : How to read data from Cassandra with R?.
library(RJDBC)
drv <- JDBC("org.apache.cassandra.cql.jdbc.CassandraDriver",
list.files("C:/Program Files/DBeaver/jre/lib",
pattern="jar$",full.names=T))
But this throws error
Error in .jfindClass(as.character(driverClass)[1]) : class not found
None of the answers are working for me from the above link.I am using latest R version 3.4.0 (2017-04-21) and New version of DBeaver : 4.0.4.
For your first approach, which I am less familiar with, should you not have a line that sets the use of the connection?
such as:
library(RCassandra)
c <- RC.connect(host ="52.0.15.195", port = 9042)
RC.login(c, username = "*****", password = "******")
RC.use(c, "some_db")
Did you check logs that you are not getting some silent error while connecting?
For your second approach, your R program is not seeing a driver in a classpath for Java (JMV).
See this entry for help how to fix it.

The used command is not allowed with this MySQL version within R Studio

I have a MYSQL (which I'm very new to) database hosted on azure, which i'm trying to write data to from RStudio using the RMySQL package.
I am receiving the following message
> dbWriteTable(searchdb,"searchrecords",data, append = TRUE)
Error in .local(conn, statement, ...) :
could not run statement: The used command is not allowed with this MySQL version
Can anybody provide a suggestion as to why this may be?

Connection R to Cassandra using RCassandra

I have an instance of Cassandra running on my localhost. For this example I have used the default configuration provided in conf\cassandra.yaml
I tried to connect R to Cassandra using the RCassandra package.
Basically, i have just installed the RCassandra package in R and tried to connect.
library("RCassandra")
RC.connect('localhost','9160')
RC.connect('127.0.0.1','9160')
None of those are working. Here is the error I get:
Error in RC.connect("localhost", port = "9160") :
cannot connect to locahost:9160
Using Cassandra-cli with the same parameters work. Can you please help on that.
Thank you
Set start_rpc: true in cassandra.yaml file.
Could not fix it but found a way to make it work: initiate a jdbc connection and then launch RCassandra
#Load RJDBC
library(RJDBC)
#Load in the Cassandra-JDBC diver
cassdrv <- JDBC("org.apache.cassandra.cql.jdbc.CassandraDriver",
list.files("C://Users//aab_ITSolutions//apache-cassandra-1.0.10//lib",pattern="jar$",full.names=T))
#Connect to Cassandra node and Keyspace
casscon <- dbConnect(cassdrv, "jdbc:cassandra://localhost:9160/DEMO")
#Query timeseries data
res <- dbGetQuery(casscon, "select * from StockHist limit 10")
library("RCassandra")
connx = RC.connect('localhost',9160)

Resources