Jump to content

AutoIT locking my Oracle account


 Share

Recommended Posts

Hello,

 

I am new to AutoIT and I am wondering if there is a setting that I am unknowingly using, that is locking me out of my Oracle account? The lines I am using is below and I am just trying to establish and test the connection. Is the "1" in the Provider name the culprit? It has happened a couple of times already that I run the script below (which by the way it is not working, I need to find the Oracle driver and other files required for it to work properly), and when I go back to try to use SQL Developer or TOAD and it tells me that I have been locked out. Since I want to continue testing the connection using AutoIT I don't want to keep asking the helpdesk to reset my password. I should mention that It is not a forgetfullness error as I write down my passwords in a log.

 

#include <array.au3>

$ps_User='xxxxx'
$ps_Pass='xxxxxx'
$ps_Port='xxxx'
$ps_Database ='xxxxxxxx' ; Schema name
$ps_Hostname ='xxxx.US.xxxx.xxxx' ; Server name

 

$sqlCon = ObjCreate("ADODB.Connection")
$sqlCon.Open ("Provider=OraOLEDB.Oracle.1="&$ps_User&";Password="&$ps_Pass&";Database="&$ps_Database&";Port="&$ps_Port&";Hostname="&$ps_Hostname&";")
$sQuery="select * from xxxx"
$aResults=__GetRecords($sQuery, $sqlCon)
_ArrayDisplay($aResults)

 

 

Thanks for your help!

XC

Link to comment
Share on other sites

Welcome to the forum. I am not familiar with Oracle, but I doubt this has anything to do with AutoIt. However you have not posted the function __GetRecords() , so it is impossible to tell what that function actually does. When you post code, please use code tags. Look for the button with the symbols <>.

Link to comment
Share on other sites

Thank you czardas, the function to get errors and records is below:

$oMyError = ObjEvent("AutoIt.Error","MyErrFunc")
Func MyErrFunc()
  $HexNumber=hex($oMyError.number,8)
  MsgBox(0,"","_______------- Error -------_______"       & @CRLF & _
             "err.description is: "    & @TAB & $oMyError.description    & @CRLF & _
             "err.windescription:"     & @TAB & $oMyError.windescription & @CRLF & _
             "err.number is: "         & @TAB & $HexNumber              & @CRLF & _
             "err.lastdllerror is: "   & @TAB & $oMyError.lastdllerror   & @CRLF & _
             "err.scriptline is: "     & @TAB & $oMyError.scriptline     & @CRLF & _
             "err.source is: "         & @TAB & $oMyError.source         & @CRLF & _
             "err.helpfile is: "       & @TAB & $oMyError.helpfile       & @CRLF & _
             "err.helpcontext is: "    & @TAB & $oMyError.helpcontext _
            )
  SetError(0)  ; to check for after this function returns
Endfunc

;here is where the earlier code with the variables I pass to the connection goes...

Func __GetRecords($query,$connection)
                $sqlRs = ObjCreate("ADODB.Recordset")
                ConsoleWrite($query&@CRLF)
                $sqlRs.Open ($query,$connection)
                                If $sqlRs.EOF = True Then
                                                SetError(1)
                                                $sqlRs.Close
                                Else
                                                $result = $sqlRs.GetRows
                                                If UBound($result)>0 Then
                                                                Return $result
                                                                $sqlRs.Close
                                                Else
                                                                $sqlRs.Close
                                                                SetError(2)
                                                EndIf
                                EndIf
EndFunc

Edited by XC
more info
Link to comment
Share on other sites

  • Moderators

You need to add some error checking at each point, to find out where it is failing. Something like this should give you an idea:

#include <array.au3>

$ps_User='xxxxx'

$ps_Pass='xxxxxx'

$ps_Port='xxxx'

$ps_Database ='xxxxxxxx' ; Schema name
$ps_Hostname ='xxxx.US.xxxx.xxxx' ; Server name

 

$sqlCon = ObjCreate("ADODB.Connection")
    If Not IsObj($sqlCon) Then MsgBox(64, "", "Error creating Connection Object")
    
$sqlCon.Open ("Provider=OraOLEDB.Oracle.1="& $ps_User &";Password=" & $ps_Pass & ";Database=" & $ps_Database & ";Port=" & $ps_Port & ";Hostname=" & $ps_Hostname & ";")
    If @error Then MsgBox(64, "", "Error opening Connection")
    
...

As the open statement is most likely the cause of your problem (and thus locking your account), I would try writing the connection string out rather than using variables. If that works, then write out the string with variables and compare to ensure it is not a syntactical issue. Something like this:

#include <array.au3>

$ps_User='xxxxx'

$ps_Pass='xxxxxx'

$ps_Port='xxxx'

$ps_Database ='xxxxxxxx' ; Schema name
$ps_Hostname ='xxxx.US.xxxx.xxxx' ; Server name

 
ConsoleWrite("Provider=OraOLEDB.Oracle.1=Jimmy;Password=Password123;Database=Database1;Port=21449;Hostname=MyDBServer;"
ConsoleWrite("Provider=OraOLEDB.Oracle.1="& $ps_User &";Password=" & $ps_Pass & ";Database=" & $ps_Database & ";Port=" & $ps_Port & ";Hostname=" & $ps_Hostname & ";" & @CRLF)

;Do these look the same? When you add error checking, does one work and not the other?

 

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

XC,

I suspect you leave an open query in your function: on successfully getting the resultset, you Return immediately (the .Close method is never called in this branch).
 

Func __GetRecords($query,$connection)
                $sqlRs = ObjCreate("ADODB.Recordset")
                ConsoleWrite($query&@CRLF)
                $sqlRs.Open ($query,$connection)
                                If $sqlRs.EOF = True Then
                                                SetError(1)
                                                $sqlRs.Close
                                Else
                                                $result = $sqlRs.GetRows
                                                If UBound($result)>0 Then
                                                                Return $result ; ### swap these 
                                                                $sqlRs.Close   ; ### two lines
                                                Else
                                                                $sqlRs.Close
                                                                SetError(2)
                                                EndIf
                                EndIf
EndFunc

 

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...