更新到R 4.2.0后,在DB2 (AS400)数据库上看不到任何对象



当我使用最近发布的R 4.2.0通过ODBC连接到DB2数据库时,数据库似乎没有对象。连接到AWS没有这样的问题,并且对象使用旧版本的r是可见的。

我在Windows 10上,并连接到DB2数据库(iSeries/AS400)。我正在使用odbc连接。

我可以使用以前版本的R进行连接(64位R4.0.2和32位R4.1.3 -差异的原因是与64位版本的r4.1冲突。x和我的OS版本,但那是另一个故事)。

我最近安装的R4.2.0似乎工作良好。它运行R代码,我可以通过ODBC连接到并查询AWS——但是当我尝试连接到DB2数据库时,奇怪的事情发生了——连接似乎是成功的,但数据库似乎不包含任何对象。查询失败,产生各种错误代码——其中一些包含一些非字符(但大多数是拉丁字母的英语)。使用旧版本的R,一切正常工作-我可以连接和查询DB2数据库。

Windows上R4.2.0的变化之一是字符集,我尝试将字符集设置为旧版本R中使用的默认值,但这并不能解决问题。我已经尝试使用RODBC包,但有类似的问题。

我使用的代码如下:

library(tidyverse)
library(odbc)
# Connect to DB --------------------------------------------------------
conn <- dbConnect(odbc(),
Driver = "iSeries Access ODBC Driver",
Server = "my.server.location",
system = "MySystemName",
uid = rstudioapi::askForPassword(prompt = "What is your user name?"),
pwd = rstudioapi::askForPassword(prompt = "What is your password?"))

我的会话信息是:

R version 4.2.0 (2022-04-22 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19044)
Matrix products: default
locale:
[1] LC_COLLATE=English_United Kingdom.utf8  LC_CTYPE=English_United Kingdom.utf8   
[3] LC_MONETARY=English_United Kingdom.utf8 LC_NUMERIC=C                           
[5] LC_TIME=English_United Kingdom.utf8    
attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     
other attached packages:
[1] odbc_1.3.3      forcats_0.5.1   stringr_1.4.0   dplyr_1.0.8     purrr_0.3.4     readr_2.1.2     tidyr_1.2.0    
[8] tibble_3.1.6    ggplot2_3.3.5   tidyverse_1.3.1

注意:这是我的第一个问题,所以如果我错过了一个好的练习,我很抱歉。

我通过将CCSID = 1252添加到dbConnect调用来解决这个问题。R 4.2切换为unicode编码,所以如果你想使用其他编码,你必须特别告诉它。

最新更新