Zend_db on iSeries - can't find database

Trying to use Zend_db on our iseries(as400) server. When running this simple test code. I get this error:
Getting connection...
Relational database J3000 not in relational database directory. SQLCODE=-950

I have been using Zend in may applications on this server but not a lot of the framework. I have many php applications that query this database successfully using db2_exec() and the other db2 functions built into php.

I can't figure out why Zend_db gripes when trying to connect to this or any other database on this server.
require_once ("Zend/Db.php");
try {
$params = array (
'host' => 'localhost',
'username' => 'username',
'password' => 'password',
'dbname' => 'J3000'
$db = Zend_Db::factory ( 'Db2', $params );
echo "Getting connection...<br />\n";
echo "Closing connection...<br />\n";
} catch ( Zend_Db_Adapter_Exception $e ) {
echo get_class ( $e ) . "<br />\n";
echo $e->getMessage() . "<br/>\n";
} catch ( Zend_Exception $e ) {
echo get_class ( $e ) . "<br />\n";
echo $e->getMessage() . "<br />\n";

Open in new window

Who is Participating?
mhopkins9901Connect With a Mentor Author Commented:
Posted to soon. I figured it out. On and as400 you have to use WRKRDBDIRE to make sure you are working with a RDB that is actually in the Relational Database Directory for this to work.

Changed conncetion params to
$params = array (
'host' => 'localhost',
'username' => 'nobody', //or what ever user the web server runs under
'password' => '',
'dbname' => 'XXXXXXX' //the entry that is in the RDB directory.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.