oracle connection open error
Asked Answered
R

3

8

I use QTP/UFT for my application testing. I had to access my oracle DB (11g) to do some DB setup (to update records).

I use oracle.manageddataaccess.dll (referenced to myDBWrapper class library project).

I have below dlls

(myDBWrapper is the one I created - where the issue is present)

enter image description here

My connection string:

Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=<HOST>)(PORT=<PORT>>)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=<SERVICENAME>)));User Id=<USERNAME>;Password=<PASSWORD>;

Issue:

The below code during conn.open() throws error. It works sometimes & sometimes throws an error that 'Object reference not to set an instance of an object' in the same machine.

conn = New OracleConnection()
conn.ConnectionString = ConnectionString
MsgBox("isnothing? : " & (conn Is Nothing).ToString)   'it is always False. So , not null

conn.Open()  ' It throws an error that "Object reference not to set an instance of an object"

Dim cmd As OracleCommand = New OracleCommand(strQuery)
cmd.BindByName = True
cmd.Connection = conn
RowsAffected = cmd.ExecuteNonQuery()
cmd.Dispose()
conn.Dispose()

Note:

It is not a resource leak. I just make 1 connection and dispose. No one else is connecting to the DB.

Issue happens - When QTP has COM lib. When i use that to automate & make it invisible (QTP.Visible = FALSE). If I use QTP.Visible = TRUE - issue does not happen. What kind of issue is this!!!

StackTrace :

Object reference not set to an instance of an object.
   at OracleInternal.I18N.Conv.GetMaxBytesPerChar(Int32 charsetId)
   at OracleInternal.ServiceObjects.OracleConnectionImpl.Connect(ConnectionString cs, Boolean bOpenEndUserSession)
   at OracleInternal.ConnectionPool.PoolManager`3.CreateNewPR(Int32 reqCount, Boolean bForPoolPopulation, ConnectionString csWithDiffOrNewPwd)
   at OracleInternal.ConnectionPool.PoolManager`3.Get(ConnectionString csWithDiffOrNewPwd)
   at OracleInternal.ConnectionPool.OraclePoolManager.Get(ConnectionString csWithNewPassword)
   at OracleInternal.ConnectionPool.OracleConnectionDispenser`3.Get(ConnectionString cs, PM conPM, ConnectionString pmCS, SecureString securedPassword, SecureString securedProxyPassword)
   at Oracle.ManagedDataAccess.Client.OracleConnection.Open()
   at myDBWrapper.Utility.DBUtil.OpenConnection()
Republicanism answered 21/2, 2015 at 15:55 Comment(10)
Please show a complete stack trace.Muskellunge
@OldProgrammer, thanks for checking. added stacktrace.Republicanism
@OldProgrammer,As an additional info, QTP is an automation tool. it can import .net dll and use its methods. In the GUI mode , it works awesome. In the non-GUI mode - it throws error. happens in both 64 and 32 bit machines. all other dlls are working in non gui mode. I would love to give any info you need to get this issue fixed.Republicanism
@TheBlastOne, thanks for checking this. Yes, i also mentioned the same in my question - in the stacktrace.Republicanism
Seems to me like a bug in OracleInternal.I18N... I don't know if there is anything you can do about it.Chitchat
Possible workaround: start hidden, un-hide for just the connect, then re-unhide. Also, you can config qtp to be minimized, I think, and still have "visible" status.Techy
@TheBlastOne, The problem is - I have a driver.vbs which uses QTP's AOM - it should hide QTP during the startup. Once QTP is invoked, it starts executing all the actions. There is a global object initialized using dotnetfactory with the dll by QTP once QTP is invoked. If i have to make it un-hide again, i need a separate function in QTP to do this as driver.vbs can not handle this as it is a separate process. For the time being i am not using hidden mode due to this issue. But I would like to use hidden mode to improve the overall performance. Thanks for checking.Republicanism
Qtp can find its own instance of AOM (there is only one), and toggle "visible" from within the action script code, no?Techy
@TheBlastOne, Yes, it is doable.Republicanism
Sorry if I am missing something but UFT doesn't support VB.NET. It uses VBScript instead. And in my project i use Adodb object to connect to oracle DB from VBScript.Buccinator
A
1

Because that looks like VB.NET Have you got that code in a form load? That event is unpredictable if you are not showing the form.

Aeolis answered 30/4, 2015 at 18:21 Comment(0)
L
-1

have u tried the oracle connection using the ADOB connection object ? you need to have the Oracle driver installed and it will help you to connect to the DB by creation the ADOB connection object

Lipchitz answered 30/4, 2015 at 19:5 Comment(1)
This should probably be a comment rather than an answerIleanaileane
T
-1

Try this

conn = New Oracle.ManagedDataAccess.Client.OracleConnection(ConnectionString)
Tomi answered 23/12, 2015 at 12:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.