I am trying to connect IBM-DB2
database using odbc_connect
. Below is the sample script to test the connection for IBM-DB2
Database
$conn = odbc_connect("DRIVER={IBM DB2};SERVER=10.100.200.99;DATABASE=TESTDB;","john","doe");
if (!($conn)) {
echo "<p>Connection to DB via ODBC failed: ";
echo odbc_errormsg ($conn );
echo "</p>\n";
}
When executed in Windows it throws below exception
Warning: odbc_connect(): SQL error: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified, SQL state IM002
When executed in Linux it throws below exception
Warning: odbc_connect(): SQL error: [unixODBC][IBM][CLI Driver] SQL30081N A communication error has been detected. Communication protocol being used: "TCP/IP". Communication API being used: "SOCKETS". Location where the error was detected: "127.0.0.1"
- How could I resolve above error and connect to
IBM-DB2
database?