Jump to content

DB2 connection problem


Recommended Posts

i have this command

$sqlCon = ObjCreate("ADODB.Connection")

$sqlCon.Open ("Provider='IBMDADB2';Data Source='maindb';UID='db2admin';Password='pass'")

The command returns me this error:

OK

We intercepted a COM Error !

err.description is: SQL30082N Security processing failed with reason "24" ("USERNAME AND/OR PASSWORD INVALID"). SQLSTATE=08001

err.windescription: .

err.number is: 80020009

err.lastdllerror is: 0

err.scriptline is: 81

err.source is: IBM OLE DB Provider for DB2

err.helpfile is:

err.helpcontext is: 0

I have tried in Administrative tool -> Data Sources (ODBC) and it's working. What is wrong in my script?

Link to comment
Share on other sites

i have this command

$sqlCon = ObjCreate("ADODB.Connection")

$sqlCon.Open ("Provider='IBMDADB2';Data Source='maindb';UID='db2admin';Password='pass'")

The command returns me this error:

OK

We intercepted a COM Error !

err.description is: SQL30082N Security processing failed with reason "24" ("USERNAME AND/OR PASSWORD INVALID"). SQLSTATE=08001

err.windescription: .

err.number is: 80020009

err.lastdllerror is: 0

err.scriptline is: 81

err.source is: IBM OLE DB Provider for DB2

err.helpfile is:

err.helpcontext is: 0

I have tried in Administrative tool -> Data Sources (ODBC) and it's working. What is wrong in my script?

It would appear your "USERNAME AND/OR PASSWORD" are "INVALID"...

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

i did said: I have tried in Administrative tool -> Data Sources (ODBC) and it's working

...and you copy/pasted the same account/password from the script? I ask because all the SQL stuff I do uses Windows Authentication only, so I don't routinely even see login prompts when testing databases. The logged in account (or RunAs credentials) either work or don't with no username/password provided ("TrustedConnection=True"). So it's not a slam dunk to me that your script's credentials are good because your (perhaps different) account can connect from ODBC manager.

Assuming you did in fact test those credentials, are there any special characters in the user name or password that might not be interpreted correctly in the string format? Also, is the local/domain context the same where the script is running and where you tested from ODBC?

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

...and you copy/pasted the same account/password from the script? I ask because all the SQL stuff I do uses Windows Authentication only, so I don't routinely even see login prompts when testing databases. The logged in account (or RunAs credentials) either work or don't with no username/password provided ("TrustedConnection=True"). So it's not a slam dunk to me that your script's credentials are good because your (perhaps different) account can connect from ODBC manager.

Assuming you did in fact test those credentials, are there any special characters in the user name or password that might not be interpreted correctly in the string format? Also, is the local/domain context the same where the script is running and where you tested from ODBC?

:)

can you write me a full sintax connection? the user and pass are the same (copy/paste).

Edited by carabusu
Link to comment
Share on other sites

Hey,

I'm interested in this too. Never tested to connect to DB2 via Autoit. I'll give a try. Hopefully someone did it before and can post some lines.

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

@all

Maybe this can get you going.

;
; where [ip_address] is the IP address of the database server, [port_number] is the port for the database server, 
; [database_name] is the name of the database, 
; and [username] and [password] are the username and password required for accessing the database.

$sqlCon.Open ("Driver={DB2}; IP=[ip_address]; Port=[port_number]; Database=[database_name]; UID=[username]; PWD=[password]")
If @error Then
    MsgBox(0, "ERROR", "Failed to connect to the database")
    Exit
EndIf

http://ns7.webmasters.com/caspdoc/html/syn...rings.htm"</a>">Connectionless DB2

Not tested though, I don't have an AS400 around to play with.

regards

ptrex

Link to comment
Share on other sites

@all

Maybe this can get you going.

;
; where [ip_address] is the IP address of the database server, [port_number] is the port for the database server, 
; [database_name] is the name of the database, 
; and [username] and [password] are the username and password required for accessing the database.

$sqlCon.Open ("Driver={DB2}; IP=[ip_address]; Port=[port_number]; Database=[database_name]; UID=[username]; PWD=[password]")
If @error Then
    MsgBox(0, "ERROR", "Failed to connect to the database")
    Exit
EndIf

Connectionless DB2

Not tested though, I don't have an AS400 around to play with.

regards

ptrex

Thanks, I'll give it a go. Besides, I do have a AS400 to play with :)

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

Mega has all the cool geek toys!

:)

;) I work in a EDPC (electronic data processing center) for banks. So we do need that power.

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

@Xenobiologist

If you have the example going.

Please post back the solution.

Thanks

ptrex

HI,

at the moment there is no need to go for a trial and error session on this. But, if ... then I'll post the result.

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

HI,

I thought about giving this a try. The problem is connecting needs either a JBDC Typ 4 driver or cataloged db.

I will install a db2 db on my localhost and see whether I can connect to it and maybe afterwards I try to connect to some zOS and AIX ones.

Anybody you already did that with VB or even Autoit, please post your code.

Global $g_eventerror = 0 ; to be checked to know if com error occurs. Must be reset after handling.
$oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") ; Install a custom error handler
Global $sqlCon = ObjCreate("ADODB.Connection")
If Not IsObj($sqlCon) Then ConsoleWrite("! Error" & @CRLF)
$sqlCon.Open("DRIVER={IBMDADB2}; IP=; PORT=; DSN=; UID=; PWD=")
If @error Then
    MsgBox(0, "ERROR", "Failed to connect to the database")
    Exit
EndIf
Func MyErrFunc()
    Local $HexNumber = Hex($oMyError.number, 8)
    ConsoleWrite("> We intercepted a COM 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 & @CRLF)
    $g_eventerror = 1 ; something to check for when this function returns
EndFunc   ;==>MyErrFunc

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

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...