Error with I5_connect

Error with I5_connect

Postby deathcomp on Mon Feb 13, 2012 5:21 pm

We are very new to zend. We just installed zend for ibmi 5.6 and now we have created a very basic script that it just trying to do an I5_connect and we get an error. We are on v6r1 if that makes a difference. I've copied out script as well as the errors generated. Any help would be greatly appreciated. It''s very possible we have something setup wrong here as we are just getting our feet wet.
Code: Select all
<?php
require_once('CW/cw.php');

if (!defined('DATABASE'))
      define('DATABASE', "dbname");
if (!defined('USER'))
      define('USER', "user");
if (!defined('PASSWORD'))
      define('PASSWORD','pass');

$conn = i5_connect(DATABASE, USER, PASSWORD);

if (!$conn) {

   $error = i5_error();

   echo " Error during connection\n";

   echo "<BR> Error number: ".$error["num"];

   echo "<BR> Error category: ".$error["cat"];

   echo "<BR> Error message: ".$error["msg"];

   echo "<BR> Error description: ".$error["desc"];

   trigger_error("I5 connection fails", E_USER_ERROR);

} else {

   echo " Connection OK ";

}
?>

Error from zend admin:

[13-Feb-2012 11:14:20] PHP Fatal error: Uncaught exception 'Exception' with message 'SQL system error. SQLCODE=-901' in /usr/local/zendsvr/share/ToolkitApi/ToolkitService.php:92
Stack trace:
#0 /usr/local/zendsvr/share/ToolkitApi/CW/cwclasses.php(30): ToolkitService->__construct('*LOCAL', '', '', '', false)
#1 /usr/local/zendsvr/share/ToolkitApi/CW/cwclasses.php(39): ToolkitServiceCw->__construct('*LOCAL', '', '', '', false)
#2 /usr/local/zendsvr/share/ToolkitApi/CW/cw.php(555): ToolkitServiceCw::getInstance()
#3 /www/zendsvr/htdocs/development/testing/i5test01.php(19): i5_error()
#4 {main}
thrown in /usr/local/zendsvr/share/ToolkitApi/ToolkitService.php on line 92
deathcomp
 
Posts: 26
Joined: Mon Feb 13, 2012 5:17 pm

Re: Error with I5_connect

Postby deathcomp on Mon Feb 13, 2012 5:49 pm

Ok figured part of it out. I didn't have the ccsid set in the http.conf file. So after doing that we now get this message from the script:

Error during connection
Error number: 78
Error category: 6
Error message: Undefined host
Error description: Check toolkit.ini for host "S10BE34P".

I thought I had the host defined correctly, but I'm not sure. Here's what I have in toolkit.ini:

Code: Select all
;toolkit.ini

[hosts]
; map ip/host names to database names (WRKDBRDIRE)

; two keys are set by default
localhost = "*LOCAL"
localhost = "S10BE34P"
127.0.0.1 = "*LOCAL"

; examples of other mappings
;1.2.3.4 = DB1
;myhost = MAINDB
;example.com = LPARDB

[log]
; warnings and errors will be written to the logfile
; TODO: debug mode for informational messages
logfile = "/usr/local/zendsvr/share/ToolkitApi/toolkit.log"


[system]
; set library where XTOOLKIT lives, most likely XMLSERVICE (testing) or ZENDSVR (production)
XMLServiceLib = "ZENDSRV"

; debug turns PHP toolkit's debug mode on or off (true/false). If true, debug xml will be placed in /tmp
debug = true

; stateless by default for i5_connect
stateless = true

; encoding
encoding = "ISO-8859-1"


[demo]
demo_library=CWDEMO


Here's my wrkrdbdire:
Position to . . . . . .

Type options, press Enter.
1=Add 2=Change 4=Remove 5=Display details 6=Print details

Remote
Option Entry Location Text

DOMINO 192.168.1.158 Remote Connection to D
S10BE34P *LOCAL



So anyone know what we are still missing?
deathcomp
 
Posts: 26
Joined: Mon Feb 13, 2012 5:17 pm

Re: Error with I5_connect

Postby aseiden on Mon Feb 13, 2012 6:26 pm

Yes, with the Compatibility Wrapper (CW), i5_connect()'s first parameter should be a hostname (IP or host), not a database name, because this API was made to be compatible with the old toolkit. (The new toolkit API does take a DB name.)

When using i5_connect(), try 'localhost' as the first parameter.

For anyone who has multiple databases, they can map the hostnames to database names in tookit.ini, under [Hosts]. For most people, though, 'localhost' works fine because it maps to '*LOCAL'.

--Alan Seiden

P.S. Again, this instruction only applies when using CW and i5_connect(). For those using ToolkitService::getInstance(), the first parameter is a DB Name such as '*LOCAL' .
aseiden
 
Posts: 711
Joined: Thu Apr 09, 2009 5:45 pm

Re: Error with I5_connect

Postby deathcomp on Mon Feb 13, 2012 7:09 pm

Where can I find information on the new toolkit?

Or maybe a better question is what's the best way to do this? We are trying to use the I5 functions like I5Spool. I don't want to start doing it an old way that happens to still work because of the compatibility tool if the new toolkit is the best way to do it.
deathcomp
 
Posts: 26
Joined: Mon Feb 13, 2012 5:17 pm

Re: Error with I5_connect

Postby aseiden on Tue Feb 14, 2012 10:25 pm

Documentation for the new toolkit Zend API is here:
http://files.zend.com/help/Zend-Server- ... ctions.htm

As for spooled files, the compatibility wrapper's (CW) support of spooled files is currently more robust than the new API's. This will change soon, but that's how it is right now. I am generally reluctant suggest the CW for people who are just starting out, but if you need spooled file support right now, you'll probably get the best results that way. Then you can use the new API for everything else. The connection object returned by CW is a new toolkit object that has access to all the methods of the new toolkit.

Let us know how it goes for you.

Alan
aseiden
 
Posts: 711
Joined: Thu Apr 09, 2009 5:45 pm

Re: Error with I5_connect

Postby aseiden on Fri Feb 17, 2012 7:42 pm

Regarding spooled files, we'd just applied a fix that makes the Zend API work pretty well for many people's spooled file needs. Give it a try and see if it meets your needs.
aseiden
 
Posts: 711
Joined: Thu Apr 09, 2009 5:45 pm

Re: Error with I5_connect

Postby deathcomp on Tue Apr 03, 2012 8:51 pm

Is that fix part of hotfix 2?
deathcomp
 
Posts: 26
Joined: Mon Feb 13, 2012 5:17 pm

Re: Error with I5_connect

Postby aseiden on Wed Apr 04, 2012 1:51 am

Yes, the spooled file fix is in hotfix 2.
aseiden
 
Posts: 711
Joined: Thu Apr 09, 2009 5:45 pm

Re: Error with I5_connect

Postby ahaithcox on Wed May 30, 2012 9:50 pm

Any plans in the near future for i5_open, _new_record, etc... support Alan? I've got quite a few script that use record level access and we've just upgraded our Zend :-( If not, what do you suggest as the best way to work around this problem (hopefully not a rewrite).
ahaithcox
 
Posts: 43
Joined: Mon Oct 03, 2011 5:22 pm

Re: Error with I5_connect

Postby aseiden on Thu May 31, 2012 3:51 am

Dear ahaitcox, If you only "upgraded" Zend Server to 5.6.0 then you should still have Easycom. If you did a fresh install then you wouldn't. Is that what happened ?

As far as I know, there are no plans to implement the record-level functions in the new toolkit. Probably the only way it would happen is if someone contributed the functionality as open source.

Alan
aseiden
 
Posts: 711
Joined: Thu Apr 09, 2009 5:45 pm

Next

Return to New Toolkit

Who is online

Users browsing this forum: No registered users and 0 guests