如何使用VBScript和UFT连接到oracle数据库? [英] How to connect to oracle database using VBScript and UFT?
问题描述
似乎在多个论坛上都提出了有关如何从UFT/VBscript连接到oracle数据库的问题.在大多数地方,答案都是零散的,没有一个详细的答案可以帮助用户获取此信息.
It seems the question on how to connect to oracle database from UFT/VBscript is asked on multiple forums. In most places, there are answers in bits and pieces, without any one detailed answer that helps user get this information.
我花了将近6天的时间来完成这项工作,因此我觉得有必要在这里分享所有详细步骤.我发现此错误的主要原因是以下一项或多项错误组合:
I spent close to 6 days to get this working and thus I feel its worth to share all the detailed steps here. The main reason I found this for going wrong is a wrong combination of one or more of below:
- 使用错误的驱动程序.
- 使用错误的连接字符串.
- 使用错误的端子来测试代码(例如,使用64位来测试32位UFT是否正常工作)
当以上任何一个错误时,我们会根据使用的驱动程序,连接字符串和终端出现一系列错误.我遇到了:
When any one of the above is wrong, we get a range of errors depending on which driver, connection string and terminal we are using. I encountered:
- 找不到提供者.可能未正确安装(使用Microsoft ODBC for Oracle时)
- "OraOLEDB.Oracle.1"提供程序未在本地计算机上注册(尝试使用oraOLEDB驱动程序时)
- 灾难性的失败. (在64位终端上运行工作脚本时)
希望以下答案将为您提供带参考的逐步答案,并提供代码示例来尝试您的代码并为您启动并运行.
Hope below answer will give you a step by step answer with references, and code examnples to try out your code and get this up and running for you.
推荐答案
-
我花了5天的时间才能正确运行此功能,尽管Internet上有可用的信息,但所有这些信息分散且指向多个方向,这可能非常耗时且令人沮丧.因此,为了避免这种麻烦,并且由于测试数据对于设置任何有意义的测试框架都至关重要,因此本节专门为您进行正确设置.希望您将不必面对我在处理此问题时遇到的同样的挫败感!
It took me 5 days to get this correctly working and although there is information available on internet, its all scattered and leads to multiple directions, which can be very time consuming and frustrating. So to save you from this frustration and also since test data is very crucial for setting up any meaningful test framework, this section is dedicated to making this properly set up for you. Hopefully, you will not have to face the same frustration that I went through in dealing with this!
要使UFT中的oracle数据库连接正常工作,请为您的oracle数据库下载32位驱动程序.为此:
To make oracle database connection work in UFT, download a 32-bit driver for your oracle database. To do this:
- 转到此页面(如果您的数据库为12c-如果另一个数据库,请转到该页面),
- 下载zip文件"win32_12201_client.zip"
- 解压缩文件并从以下文件夹运行"setup.exe":Downloads \ win32_12201_client \ client32
- 在选择您想要哪种安装类型"时,
- 选择->管理员(1.5GB)
- 使用内置帐户的Windows(第三个选项)
- 保留默认位置
- oracle base-> C:\ app \ client \ yourUserID(不允许使用空格)
- 软件位置-> C:\ app \ client \ yourUserID \ product \ 12.2.0 \ client_2
- 保存响应文件以供将来参考
- 安装产品
- Go to this page (if your database is 12c - if another database, go to that page), https://www.oracle.com/database/technologies/oracle12c-windows-downloads.html Scroll down and look for "Oracle Database 12c Release 2 Client (12.2.0.1.0) for Microsoft Windows (32-bit)" - If you are working on oracle 12C
- Download the zip file "win32_12201_client.zip"
- Extract the file and run "setup.exe" from the folder : Downloads\win32_12201_client\client32
- While selecting "What type of installation do you want",
- select -> Administrator (1.5GB)
- Use windows built in account (3rd option)
- Keep default locations for
- oracle base -> C:\app\client\yourUserID (no space in between allowed)
- software location -> C:\app\client\yourUserID\product\12.2.0\client_2
- Save response file for your future reference
- Install the product
- 在开始搜索"框中键入%windir%\ SysWoW64 \ cmd.exe.
- 将目录更改为脚本位置(例如cd c:\ Users \ yourUserID \ UFT \ Rusty \ FunctionLibrary)-如果脚本位于dir FunctionLibrary目录中
- 现在您可以通过在脚本前面编写cscript来运行该脚本-> cscript database-functions.vbs
- 您应该看到测试脚本中弹出的值.
- https://www.connectionstrings.com/oracle-in-oraclient11g_home1/(从此处使用标准格式)
- Dim connString:connString ="DRIVER = {Oracle in OraClient12Home1_32bit}; DBQ = yourHostURL:portNr/DBname; Trusted_Connection = Yes; UID = MyUser; Password = myPassword"
- Ex(具有虚拟值):connString ="DRIVER = {Oracle in OraClient12Home1_32bit}; DBQ = ab12.mycompany.com:1521/ORAB; Trusted_Connection = Yes; UID = pramod; Password = myPassword"
- https://www.connectionstrings.com/oracle-in-oraclient11g_home1/ (use standard format from here)
- Dim connString: connString = "DRIVER={Oracle in OraClient12Home1_32bit};DBQ=yourHostURL:portNr/DBname;Trusted_Connection=Yes;UID=MyUser;Password=myPassword"
- Ex (with dummy values): connString = "DRIVER={Oracle in OraClient12Home1_32bit};DBQ=ab12.mycompany.com:1521/ORAB;Trusted_Connection=Yes;UID=pramod;Password=myPassword"
- https://github.com/PramodKumarYadav /Rusty/blob/master/FunctionLibrary/test-data-functions.vbs
- 或在此处: https://hoopercharles.wordpress.com/2009/12/12/simple-vbs-script-to-retrieve-data-from-oracle/
- 将连接字符串更改为如上所述.
- https://github.com/PramodKumarYadav/Rusty/blob/master/FunctionLibrary/test-data-functions.vbs
- Or here: https://hoopercharles.wordpress.com/2009/12/12/simple-vbs-script-to-retrieve-data-from-oracle/
- Change the connection string to as mentioned above.
希望这会有所帮助,比起自行设置,使用oracle连接本身来构建测试可以节省大量时间和精力.
Hope this helps and you can save a lot of time and energy in using oracle connection itself to build tests, than setting this up itself.
这篇关于如何使用VBScript和UFT连接到oracle数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
- 转到此页面(如果您的数据库为12c-如果另一个数据库,请转到该页面),