I'm trying to connect to a client's IBM AS/400 DB2 Database from an Ubuntu Server using PHP's ODBC Driver. I have the unixODBC installed as well. My odbcinst.ini looks like this:
[IBM DB2 ODBC DRIVER]
Description = ODBC 5.1 Driver for Database
Driver = /usr/lib/x86_64-linux-gnu/odbc/libmyodbc.so
FileUsage = 1
And my odbc.ini looks like this:
[IBM DB2 ODBC DRIVER]
Driver = IBM DB2 ODBC DRIVER
Description = ODBC 5.1 Driver DSN
Now, my code to connect is:
$server = '12.345.678.90' //IP
$port = '446' //PORT
$username = 'my_username';
$password = 'my_password';
$connect = odbc_connect("DRIVER = {IBM DB2 ODBC DRIVER};System=$server:$port;Uid=$username;Pwd=$password;", $username, $password);
if(!$connect)
echo 'Cannot Connect!';
else
echo 'Connected!';
The error I get is this:
Warning: odbc_connect(): SQL Error: [unixODBC][MySQL][ODBC 5.1 Driver]Access denied for user 'my_username'@'localhost' (using password: YES), SQL state S1000 in SQLConnect
I tried using the PDO ODBC Driver also. This is the error I get:
$connect = new PDO("odbc:DRIVER={IBM DB2 ODBC DRIVER};HOSTNAME=$server;PORT=$port;Uid=$username;Pwd=$password");
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] SQLDriverConnect: 1045 [unixODBC][MySQL][ODBC 5.1 Driver]Access denied for user 'my_username'@'localhost' (using password: YES)' in /var/www/test_file.php Stack trace: #0 /var/www/test_file.php: PDO->__construct('odbc:DRIVER={IB...') #1 {main} thrown in /var/www/test_file.php
Am I doing something wrong here? Do I need to use some other driver, because the username and password are correct, I saw the client log in to the database using the username and password I have. I thought the username and password were wrong because it says Access Denied for user. It doesn't seem to be the case. There might be something else that's wrong.
Thank you for your help. I hope I made the problem very clear. Thanks!