problem with configure PHP with IBM-DB2 driver for connecting Apache derby database

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • knellim
    New Member
    • Feb 2010
    • 23

    problem with configure PHP with IBM-DB2 driver for connecting Apache derby database

    Hi All,

    I am trying to configure php with IBM-DB2 and I get the followinng when i run the configure command

    ./configure --with-pdo-odbc=ibm-db2,/opt/IBM/db2/V8.1/

    THE OUTPUT:

    checking for ODBC v3 support for PDO... yes
    checking for PDO includes... checking for PDO includes... /home/knellim/php-5.3.1/ext
    checking for selected PDO ODBC flavour... ibm-db2
    libs /opt/IBM/db2/V8.1//lib,
    headers /opt/IBM/db2/V8.1//include
    checking for odbc.h in /opt/IBM/db2/V8.1//include... no
    checking for odbcsdk.h in /opt/IBM/db2/V8.1//include... no
    checking for iodbc.h in /opt/IBM/db2/V8.1//include... no
    checking for sqlunix.h in /opt/IBM/db2/V8.1//include... no
    checking for sqltypes.h in /opt/IBM/db2/V8.1//include... no
    checking for sqlucode.h in /opt/IBM/db2/V8.1//include... no
    checking for sql.h in /opt/IBM/db2/V8.1//include... yes
    checking for isql.h in /opt/IBM/db2/V8.1//include... no
    checking for sqlext.h in /opt/IBM/db2/V8.1//include... yes
    checking for isqlext.h in /opt/IBM/db2/V8.1//include... no
    checking for udbcext.h in /opt/IBM/db2/V8.1//include... no
    checking for sqlcli1.h in /opt/IBM/db2/V8.1//include... yes
    checking for LibraryManager. h in /opt/IBM/db2/V8.1//include... no
    checking for cli0core.h in /opt/IBM/db2/V8.1//include... no
    checking for cli0ext.h in /opt/IBM/db2/V8.1//include... no
    checking for cli0cli.h in /opt/IBM/db2/V8.1//include... no
    checking for cli0defs.h in /opt/IBM/db2/V8.1//include... no

    So basically, I have installed the DB2 runtime client but there are no header files in that needed for the succesful connection to Apache Derby database.

    When i run my connect php script i get error message
    SQLSTATE[IM002] SQLConnect: 0 [unixODBC][Driver Manager]Data source name not found, and no default driver specified

    PLEASE, anyome who has configured PHP with IBM-DB2 pls help me.. Its urgent!!
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    how do you connect to the DB?

    Comment

    • Markus
      Recognized Expert Expert
      • Jun 2007
      • 6092

      #3
      Please see this page on php.net.

      Comment

      • knellim
        New Member
        • Feb 2010
        • 23

        #4
        I connect to the DB using the CATALOG TCPIP command. My database is located on the same machine.
        I start the Derby Network serveri in Opt/Apache/derby/bin by giving
        # ./startNetworkser ver&

        The database created is named as vcl
        Then, I start the DB2 CLI and give the below commands
        db2=>catalog tcpip node vclnode remote localhost server 1527
        db2=>catalog db VCL at node vclnode authetication server
        db2=>connect to VCL user vcluser using vclPassw

        This connectd my DB2 client and derby database as I can see tables by giving select command,

        Can u help me in connecting PHP with DB2. Thanks....in advance

        Comment

        • Markus
          Recognized Expert Expert
          • Jun 2007
          • 6092

          #5
          Originally posted by knellim
          I connect to the DB using the CATALOG TCPIP command. My database is located on the same machine.
          I start the Derby Network serveri in Opt/Apache/derby/bin by giving
          # ./startNetworkser ver&

          The database created is named as vcl
          Then, I start the DB2 CLI and give the below commands
          db2=>catalog tcpip node vclnode remote localhost server 1527
          db2=>catalog db VCL at node vclnode authetication server
          db2=>connect to VCL user vcluser using vclPassw

          This connectd my DB2 client and derby database as I can see tables by giving select command,

          Can u help me in connecting PHP with DB2. Thanks....in advance
          Did you see my reply?

          Comment

          • knellim
            New Member
            • Feb 2010
            • 23

            #6
            I only saw ur last reply asking me how I connect to DB.. I did answer that and i m waiting fr ur resonse...

            Comment

            • Markus
              Recognized Expert Expert
              • Jun 2007
              • 6092

              #7
              That wasn't my reply. See #3.

              Comment

              • knellim
                New Member
                • Feb 2010
                • 23

                #8
                oh yaa..i saw that.. I am following the steps now.. I will try it and tell u if thagt worked..

                Comment

                • knellim
                  New Member
                  • Feb 2010
                  • 23

                  #9
                  Hi Marcus,

                  I have the ibm_db2 driver configured. I made the changes to php.ini file as
                  extension=pdo.s o
                  extension=ibm_d b2.so
                  ibm_db2.instanc e_name=knellim

                  I have written php file in /var/www/html as
                  Code:
                  <?php
                  // Create the uncataloged connection string
                   $DSN = "DRIVER={IBM DB2 ODBC DRIVER};PROTOCOL=TCPIP;"
                           . "DATABASE='TEST';HOSTNAME='localhost';PORT=1527;"
                           . "UID='knellim';PWD='db2';";
                  $conn = db2_connect($DSN,null,null);
                  $sql = "SELECT id FROM resource";
                  $stmt = db2_prepare($conn, $sql);
                  $res = db2_execute($stmt, array(10));
                  while ($row = db2_fetch_assoc($res)) {
                  print "{$row['id']}\n";
                  }
                  ?>
                  and when i run it I as php connect.php , I get

                  PHP Warning: db2_prepare() expects parameter 1 to be resource, boolean given in /var/www/html/testvcl.php on line 9
                  PHP Warning: db2_execute() expects parameter 1 to be resource, null given in /var/www/html/testvcl.php on line 10
                  PHP Warning: db2_fetch_assoc () expects parameter 1 to be resource, null given in /var/www/html/testvcl.php on line 11

                  Pls can u help me with this.. Any idea why this is happening..??
                  Last edited by Dormilich; Feb 19 '10, 10:44 PM. Reason: Please use [code] tags when posting code

                  Comment

                  • knellim
                    New Member
                    • Feb 2010
                    • 23

                    #10
                    PHP connection failing to Derby db

                    I wrote a simple script for testing my connection
                    Code:
                    <?php
                    
                    $database = 'VCL';
                    $user = 'vcluser';
                    $password = 'vcluserpassword';
                    
                    $conn = db2_connect($database, $user, $password);
                    
                    if ($conn) {
                        echo "Connection succeeded.";
                        db2_close($conn);
                    }
                    else {
                        echo "Connection failed.";
                    }
                    ?>

                    It says Connection failed

                    Whats the username and password to be given there.. Is it the database user name and passw or DB2 instance username and password??

                    Please suggest
                    Last edited by Dormilich; Feb 19 '10, 10:47 PM. Reason: Please use [code] tags when posting code

                    Comment

                    • Dormilich
                      Recognized Expert Expert
                      • Aug 2008
                      • 8694

                      #11
                      you simple fail to connect, so db2_connect() returns false. have you tried PDO, you installed the PDO driver after all?

                      Comment

                      • Dormilich
                        Recognized Expert Expert
                        • Aug 2008
                        • 8694

                        #12
                        Whats the username and password to be given there.. Is it the database user name and passw or DB2 instance username and password??
                        like the manual says, the login/password of the DB.

                        Comment

                        • knellim
                          New Member
                          • Feb 2010
                          • 23

                          #13
                          Yes , I do have the pdo driver
                          I did php -m and it shows me the PHP modules which has the PDO

                          Comment

                          • Dormilich
                            Recognized Expert Expert
                            • Aug 2008
                            • 8694

                            #14
                            you could try to connect to DB2 using PDO.

                            Comment

                            • knellim
                              New Member
                              • Feb 2010
                              • 23

                              #15
                              How can I do that.. Can u give me any example

                              Comment

                              Working...