jdbc - Connect R and Netezza using RJDBC -


i´m trying connect r netezza using jdbc driver.

i manage connect succesfully database, results not corretc.

# here connection details library(rjdbc) drv <- jdbc(driverclass="org.netezza.driver", classpath = "c://jdbc//nzjdbc.jar", "'") con <- dbconnect(drv, "jdbc:netezza://10.206.0.66:5480//dbase", "user", "pass")  # > con # object of class "jdbcconnection" # slot "jc": # [1] "java-object{org.netezza.sql.nzconnection@bce3d7}"  # slot "identifier.quote": # [1] "'"  res <- dbsendquery(con, "select * dbase.marbel.datos limit 10000;") res <- fetch(res, n = -1) 

the problem fields resturned list "vertical" variables instead of columns of table!

head(res)  subscription_id 1 245206318120314                                                                                                                                                                                                                                                 2 235109338101206                                                                                                                                                                                                                                                 3 238463669110624                                                                                                                                                                                                                                                 4 214177015090830                                                                                                                                                                                                                                                 5 212403495090830                                                                                                                                                                                                                                                 6 13874138618090824                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  sub_account_id 1 mv_subcta_45206318_20120316                                                                                                                                                                                                                                     2 mv_subcta_35109338_20101207                                                                                                                                                                                                                                     3 mv_subcta_38463669_20110627                                                                                                                                                                                                                                     4 mv_subcta_45223848_20120316                                                                                                                                                                                                                                     5 mv_subcta_12403495_20081224                                                                                                                                                                                                                                     6 mv_subcta_18932919_20091012                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            account_id 1 mv_cta_44123765_20120316                                                                                                                                                                                                                                        2 mv_cta_35213277_20101207                                                                                                                                                                                                                                        3 mv_cta_37772612_20110627                                                                                                                                                                                                                                        4 mv_cta_14217213_20090330                                                                                                                                                                                                                                        5 mv_cta_12477560_20081224                                                                                                                                                                                                                                        6 mv_cta_18758944_20091012                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         access_method_id 1 1167391804                                                                                                                                                                                                                                                      2 1159354610                                                                                                                                                                                                                                                      3 2966407995                                                                                                                                                                                                                                                      4 1153360304                                                                                                                                                                                                                                                      5 1131960835                                                                                                                                                                                                                                                      6 3874138618   

any idea how solve this?? have working odbc connection, i´d rather use jdbc.

i scrolled output way right , looks strings in columns wide (are char instead of varchar?), result not fit width of r console. hence r displays them way.

so try either trim them in query

select rtrim(sub_account_id), ... 

or in r:

require('stringr') res$sub_account_id <- str_trim(res$sub_account_id) 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -