更新为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位版本的R 4.1.X发生冲突,但这是另一个故事)。
我最近安装的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
注意:这是我的第一个问题,因此,如果我错过了良好的练习,我深表歉意。
When I connect to a DB2 database via ODBC using the recently released R 4.2.0 the database appears to have no objects. Connecting to AWS has no such issues, and objects a viewable using older versions of R.
I am on Windows 10, and connecting to a DB2 database (iSeries/AS400).
I am using an odbc connection.
I can connect using previous versions of R
(64-bit R4.0.2, and 32-bit R4.1.3 - the reason for the difference is conflicts with 64-bit versions of R 4.1.x with my OS build, but that's another story).
My recent install of R4.2.0 seems to work fine. It runs R code, I can connect to and query AWS via ODBC - but something weird happens when I try to connect to the DB2 database - The connection seems to be successful, but the database appears to contain no objects. Queries fail, with various error codes - some of which contain some non-lain characters (but are mostly English in latin script).
Using older versions of R, everything works as normal - I can connect to and query the DB2 database.
One of the changes in R4.2.0 on Windows is the character set, I have tried setting the character set to the default used in older versions of R, but this does not resolve the issue.
I have tried using the RODBC package, but had a similar issue.
The code I am using below:
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?"))
My session info is:
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
Note: This is my first question, so my apologies if I miss on good practice.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我通过将
ccsid = 1252
添加到dbConnect
调用来解决此问题。 R 4.2切换到Unicode编码,因此您必须具体说明是否要使用其他内容。I solved this by adding
CCSID = 1252
to thedbConnect
call. R 4.2 switched to unicode encoding, so you have to tell it specifically if you want to use something else.