设为首页 收藏本站
查看: 896|回复: 0

[经验分享] SQL1159 Initialization error with DB2 .NET Data Provider, reason code 2;reason

[复制链接]

尚未签到

发表于 2016-11-18 01:17:45 | 显示全部楼层 |阅读模式
  昨天遇到 reason code 2这个错误,找了很久,网上说权限问题,按照处理办法解决后仍然不行,后来发现除了IBM.Data.DB2.dll,还需要拷贝db2app.dll这个文件到bin目录,如果安装了DB2 Data Provide for .NET,这两个dll应该都放到全局程序集中,但是奇怪的是db2app.dll这个dll没有进去,导致找不到这个dll。
  开发环境:visual studio 2010
  数据库: IBM db2 9.7  for windows
  操作系统:windows xp sp3
  reason code 2错误提示:
  SQL1159  Initialization error with DB2 .NET Data Provider, reason code 2, tokens E:\SourceCode\DB2Test\DB2Test\bin\db2app.dll, , Process Owner: XQUANT-BFAA77C8\Administrator
  reason code 10错误提示:
  SQL1159  Initialization error with DB2 .NET Data Provider, reason code 2, tokens 0.0.0 E:\SourceCode\DB2Test\DB2Test\bin\db2app.dll
  reason code 10的错误,根据tokens返回值提示是由于权限问题,将ASP.NET用户加入到DB2ADMINS用户组,重启IIS解决。参考IBM的官网:
SQL1159 rc=10 when running a DB2 .NET application







Technote (troubleshooting)


Problem(Abstract)
  A DB2 .NET application may receive an exception as follows:
SQL1159 Initialization error with DB2 .NET Data Provider, reason code 10, tokens 0.0.0, 9.5.3
  
Cause

  An SQL1159 error may be returned if the DB2 .NET data provider had a problem during initialization.
When the DB2 .NET data provider is initialized it will perform some checks to ensure that the DB2 .NET data provider can be used properly. One of those checks is to see if it can execute a function from within the DB2 native client library called db2app.dll, and before that can be done it tries to load the db2app.dll library in memory.
Several different reason codes can be returned with the SQL1159 exception, but reason code 10 occurs when there is a mismatch between the DB2 native client library (db2app.dll) and the DB2 .NET data provider library (IBM.Data.DB2.dll).
  SQL1159 reason code 10 will return two tokens. The first token is the version of the DB2 client library, and the second token is the version of the DB2 .NET data provider.
  If the version of the DB2 client library is returned as 0.0.0, then that means that there was a problem during the initialization of the db2app.dll library.
  There are potentially two reasons why a token of 0.0.0 is returned for the native DB2 client library.
  The first is that the db2app.dll is not compatible with the version of the DB2 client that is installed. The second is that there was a permission problem when trying to use the db2app.dll library with the application process.


Resolving the problem

  Incompatible db2app.dll version
Every DB2 fixpak and release has its own version of the db2app.dll library. The file size and signature will be different for each fixpak and release. It is very important that when DB2 is installed that the db2app.dll library is the one that came from that level of DB2 that is being installed.
DB2 will update the db2app.dll library during the install of a fixpak or during the migration from one release to another. If there was a problem updating the db2app.dll, DB2 will document that in its installation log file.
Here is an example of a typical error in the DB2 install log when the db2app.dll could not be updated:
  InstallFiles: File: db2app.dll, Directory: C:\Program Files\IBM\SQLLIB\BIN\, Size: 9680160
Info 1603.The file C:\Program Files\IBM\SQLLIB\BIN\db2app.dll is being held in use. Close that application and retry.
MSI (s) (CC:B0) [11:18:48:389]: Product: DB2 Connect Server - DB2COPY1. The file C:\Program Files\IBM\SQLLIB\BIN\db2app.dll is being held in use by the following process Name: msiexec , Id 5392.

If this was the case, then it is important that all applications were shut down before upgrading DB2. This includes any applications that run as Windows services, such as an application server that might be making DB2 connections. The above error is a result of an application holding a lock on the db2app.dll file, thus disallowing DB2 from updating the file.
  To verify that the db2app.dll library is in fact compatible with the DB2 level, issue the db2level command, and then compare the level with the file version of the db2app.dll. To retrieve the file version, find the db2app.dll using Windows Explorer and right-click on it and go to Properties->Version.
  Invalid priviliges
When the db2app.dll library is initialized by the DB2 .NET data provider, it initializes an application environment. This process will ensure that the db2app.dll library can be used. Some of the things it does is it checks to see what DB2 environment variables are set, and it checks things like the client-side database manager configuration file. If the DB2 .NET data provider could not initialize the application environment properly then DB2 .NET will return 0.0.0 for the native DB2 client library version.
  The most common reason why the initialization of the application environment fails is because of invalid privileges. And the most common reason why there are invalid privileges is if DB2 Extended Security is enabled, and the userid that the application process runs under is not a member of either the DB2ADMNS or the DB2USERS groups.
  
If DB2 Extended Security is enabled (this is the default behavior for DB2 installations), then it is mandatory that any DB2 'user' belongs to either the DB2ADMNS or the DB2USERS group. This is not just the userid that is used during authentication with DB2, but it also includes the owner of the application process.
  
Some application processes like the w3wp.exe process (which is a process used by Microsoft Information Integrator (IIS)) can run under a different userid than the one that connects to DB2. It is important that this user belongs to the proper DB2 Extended Security group, if DB2 Extended Security is enabled.
  If running IIS 7, the default account used for anonymous access is called "IUSR". This user can be added to the extended security group to resolve this error.
  To determine what userid is actually trying to use the .NET application then you can use a utility called the Microsoft® Process Monitor located here:
  That utility will track all file and registry operations issued by any Windows process. If that process failed to read a file, then it will record an ACCESS DENIED error. Microsoft® Process Monitor can show who the userid was that tried to access the file when it failed. Adding that userid to the proper DB2 Extended Security group should then resolve that problem. The userid that is used by the application can be impersonated by another userid. Microsoft® Process Monitor will show who the Impersonating userid is, and that is the userid that needs to be added to the proper DB2 Extended Security group.
  If DB2 Extended Security is enabled, and the preference is to not use DB2 Extended Security, then the ideal thing to do would be to uninstall DB2 and reinstall it without the DB2 Extended Security option.
  If Microsoft Windows® 7 or Microsoft Windows Vista® are being used, and DB2 Extended Security is disabled, the problem may still occur due to invalid privileges, specifically if the userid that installed DB2 was not given elevated administrator rights. Typically when User Account Control (UAC) is enabled, users with administrator rights run with least user privileges. These rights can be elevated to perform administrative tasks. If a non-elevated administrator installed DB2 then certain Windows registry settings used by DB2 may not be set properly, preventing the DB2 .NET data provider from working properly. It is important to ensure that a userid with elevated administrator privileges has installed DB2 to resolve this problem.
  
  If using the IBM Data Server Driver Package, then you could also get this error if you were hitting APAR JR30952 (that is fixed in DB2 v9.5 FP5) or APAR IC63971 (that is fixed in DB2 v9.7 FP1). DB2 Extended Security was being enabled implicitly for the IBM Data Server Driver when it should not have been, and that would result in this error since DB2 would think that the userid running the application would not be a member in the proper DB2 Extended Security group.

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-301683-1-1.html 上篇帖子: DB2 Metadata 下篇帖子: db2 用户权限
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表