Python - Error: SQLCODE=-30082r] SQL30082N Security Processing failed with Reason "24" ("USERNAME AND/OR PASSWORD INVALID"). SQLSTATE=08001

Asked

Viewed 73 times

0

Hello! I need help with the following problem: I made a script in python to collect data from a DB2 table and generate a spreadsheet. I’m in the testing phase, but the idea is that the script will run itself every day. However, this week the table access password has expired and a new password has been generated. But this password contains the character ; and because of it my script stopped working. When the script arrives in this function:

def connect_db2(self, data_base, hostname, port, username, password):
    try:
        connection = ibm_db.connect(f"DATABASE={data_base};HOSTNAME={hostname};\
        PORT={port}; PROTOCOL=TCPIP;UID={username};PWD={password};", "", "")
        return connection
    except Exception as e:
        print(e)

the title error occurs:

SQLCODE=-30082r] SQL30082N Security processing failed with reason "24"("USERNAME AND/OR PASSWORD INVALID"). SQLSTATE=08001

I know it’s because of ; because I tested the direct access in the table and it works, only it doesn’t work in the script.

At the time the problem occurred for the first time we changed the password and worked for the tests. Now, I’m about to put into production and again the problem occurs.

I do not want to have to ask the person responsible for access to verify the password before updating to the script does not stop working, since it is an automation.

I wonder if anyone knows any way the script/ function accept the ; as part of the password.

  • force the escape of character: ;

1 answer

0

vc tried to use the DB2 string delimiter around the password string ?

connection = ibm_db.connect(f"DATABASE={data_base};HOSTNAME={hostname};PORT={port};\PROTOCOL=TCPIP;UID={username};PWD='{password}';", "", "")

I’m not sure, if it’s double quotes ('"') instead of what’s in my example, try using simple quotes in the python string.... but try the first one before reversing everything

Also These workaround won’t help Outside db2prompt for example: db2 connect to sample USER admin USING '!Xyz' SQL0104N An Unexpected token "!" was found following "". Expected tokens may include: "NEW". SQLSTATE=42601

source: https://www.ibm.com/support/pages/usernamepassword-special-characters-need-be-quoted-when-using-them-through-clp-within-db2prompt-iedb2

I don’t think there’s gonna be any 8 characters(

  • Hello! I tested with double quotes and simple, same mistake. He and understands that when :( ...

  • I put this command line : password.Ncode(encoding='UTF-8',errors='Strict') but it was the same thing...

  • password.This does not make sense to me. This error is not from Python, is from the DB2 or DB2 connector you are using. so I talked about adding the string delimiter and only in passowrd

  • Yes, I put the delimiter only in the password. The problem is that when the password value is read, the ; is understood as another parameter, so it gives the password error. I tested the password to access the tables directly in DB2 and this working.

  • give a look ... I’m out of options 8( , but take a look here and see if you can find something https://www.ibm.com/support/pages/usernamepassword-special-characters-need-be-quoted-when-using-them-through-clp-within-db2-promptiedb2

  • Good :) ! I will look yes, but anyway thank you so much :D!

Show 1 more comment

Browser other questions tagged

You are not signed in. Login or sign up in order to post.