0

I am trying to connect a db2 database using php. Now, i am gonna write some code similar to this(call a stored procedure):

$proc = 'CALL MyLib.MySP(?, ?, ?)'; 
$stmt = db2_prepare($conn, $proc) or die("db2_prepare failed<br>"); 

// Define input variable values // 
$paramIN1  = ...; 
$paramIN2  = ...; 
$paramOUT3 = ""; 

// Define parameters // 
db2_bind_param($stmt, 1, "paramIN1", DB2_PARAM_IN); 
db2_bind_param($stmt, 2, "paramIN2", DB2_PARAM_IN); 
db2_bind_param($stmt, 3, "paramOUT3", DB2_PARAM_OUT); 

// Display results set // 
if (db2_execute($stmt)) { 
    while ($row = db2_fetch_array($stmt)) { 
        print "  {$row[0]}, {$row[1]}, {$row[5]}<br>"; 
    } 
}

Connection code:

$user = 'user';
$password = 'pass';
$hostname = 'ip';
$db = 'db';
$conn_string = "DRIVER={IBM DB2 ODBC DRIVER};HOSTNAME=$hostname;PROTOCOL=TCPIP;UID=$user;PWD=$password;DATABASE=$db;";

$conn = db2_connect($conn_string, $user, $password);

Connection fails here. Error message returned from db2_conn_errormsg() is:

"[IBM][CLI Driver] SQL1032N No start database manager command was issued. SQLSTATE=57019 SQLCODE=-1032"

This is an AS/400 system. With odbc we can connect and talk to database without a problem.

3
  • That message indicates a failure to connect to the database server. Are you using the CLI Driver with your other odbc connections or the iSeries Access driver? Commented Aug 8, 2011 at 11:25
  • 1
    [IBM][CLI Driver] is the DB2 ODBC driver not the iSeries Access driver. Check your ODBC provider configuration. Commented Aug 8, 2011 at 11:34
  • Thanks, working on it but nothing so far. Commented Aug 8, 2011 at 12:42

2 Answers 2

0

[IBM][CLI Driver] is the DB2 ODBC driver not the iSeries Access ODBC driver. From what I can discern it also requires DB2 Connect to enable a connection to an AS/400 host.

A failure to connect using the iSeries Access ODBC driver results in the following message:

[IBM][iSeries Access ODBC Driver]Communication link failure. comm rc=8015 - CWBSY1006 - User ID is invalid, Password length = 0, Prompt Mode = Never, System IP Address = 127.0.0.1

Check the database driver on your ODBC DSN.

ODBC Data Source Administrator

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you for your helping. I guess you are right but still can't connect. I created new dsns with DB2 ODBC Driver and also "IBM DATA Server Driver for ODBC" which came with DB2 Connect. Only difference is when i use "IBM DATA Server Driver for ODBC" this time i get " The database alias "" could not be found in the db2dsdriver.cfg configuration file" error message. I tried to define different aliases but that didn't work either. DB2 ODBC Driver returns the same error in the question.
In a previous comment you said you were using the iSeries Access ODBC driver however that's not the driver you are configuring in your DSN. I believe you either need to switch to the iSeries Access ODBC driver or configure DB2 Connect so that you can use the DB2 ODBC Driver.
0

You can connect with db2 using:

$dbh = db2_connect('*LOCAL', $user, $password, array("i5_lib"=> $db);

If the DB2 database and the ZendServer are in the same IBM i then '*LOCAL', else the DB2 name.

1 Comment

There isn't ZendServer on IBM i. Php code runs on a different machine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.