R: How to use RJDBC to download blob data from oracle database? -


does know of way download blob data oracle database using rjdbc package?

when this:

library(rjdbc) drv <- jdbc(driverclass=..., classpath=...)  conn <- dbconnect(drv, ...)  blobdata <- dbgetquery(conn, "select blobfield blobtable id=1") 

i message:

error in .jcall(rp, "i", "fetch", stride) :    java.sql.sqlexception: ongeldig kolomtype.: getstring not implemented class oracle.jdbc.driver.t4cblobaccessor 

well, message clear, still hope there way download blobs. read 'getbinary()' way of getting blob information. can find solution in direction?

the problem rjdbc tries convert sql data type reads either double or string in java. typically trick works because jdbc driver oracle has routines convert different data types string (accessed getstring() method of java.sql.resultset class). blob, though, getstring() method has been discontinued moment. rjdbc still tries calling it, results in error.

i tried digging guts of rjdbc see if can call proper function blob columns, , apparently solution requires modification of fetch s4 method in package , result-grabbing java class within package. i'll try patch package maintainers. meanwhile, quick , dirty fix using rjava (assuming conn , q in example):

s <- .jcall(conn@jc, "ljava/sql/statement;", "createstatement") r <- .jcall(s, "ljava/sql/resultset;", "executequery", q, check=false) listraws <- list() col_num <- 1l <- 1 while(.jcall(r, 'z', 'next')){   listraws[[i]] <- .jcall(r, '[b', 'getbytes', col_num)   <- + 1 } 

this retrieves list of raw vectors in r. next steps depend on nature of data - in application these vectors represent png images , can handled pretty file connections png package.

done using r 3.1.3, rjdbc 0.2-5, oracle 11-2 , ojdbc driver jdk >= 1.6


Comments