Minggu, 24 Juli 2016

Derby database floreants POS

Connecting PHP 5.3 and Apache Derby Database


Update: Following page content is outdated. Floreant POS support mysql and its very easy to connect PHP with MySQL.

PHP Developers can connect Derby database of Floreant POS with following steps. It has been tested in PHP 5.3 and should be working in PHP 5.2

Necessary Steps
PHP has different APIs for different databases and PHP can connect to Apache Derby (formerly known as Cloudscape) with DB2 connectivity.  For successful connection we need to go with  the following steps. Examples are from Ubuntu 9.10 but it should be working other linux distributions with respective commands.

Install DB2 Express C

Download it from here . Extract and run ./db2setup

Download & Compile PHP Source code
  1. Download PHP 5.3 or the latest version. If you are using Ubuntu write
    wget http://us3.php.net/get/php-5.3.1.tar.bz2/from/us.php.net/mirror
  2. Untar source code in /usr/src
    tar -xjf php-5.x.x.tar.bz2
  3. Build make file with with desired parameters
    ./configure --with-apxs2=/usr/bin/apxs2 --with-config-file-path=/etc/php5/apache2/ --with-mysql --enable-inline-optimization --disable-debug --enable-bcmath --enable-calendar --enable-ctype --enable-dbase --enable-discard-path --enable-exif --enable-force-cgi-redirect --enable-ftp --enable-gd-native-ttf --with-ttf --enable-shmop --enable-sigchild --enable-sysvsem --enable-sysvshm --enable-wddx --with-zlib=yes --with-openssl --with-xsl  --with-gd --with-gettext --with-mcrypt --with-mhash --enable-sockets --enable-mbstring=all --enable-mbregex --enable-zend-multibyte --enable-exif --enable-soap --enable-pcntl --with-mysqli --with-mime-magic --with-iconv --with-pdo-mysql --with-freetype-dir=/usr/include/freetype2/freetype  --enable-cli -disable-cgi --with-pdo-ibm=/home/db2inst1/sqllib/

    NOTE:  If you find dependent files are missing install them. Following examples are for Ubuntu 9.10 . Other distributions should have similar commands.

    #apxs2 was not installed so updated with
    sudo apt-get install apache2-threaded-dev

    #libxm2-dev not found so installed
    apt-get install libxml2-dev

    #freetype now installed found solution: http://theserverpages.com/php/manual/en/function.imagefttext.php
    apt-get install libfreetype6-dev

    #libmcrypt not found. so installed
    sudo apt-get install libmcrypt-dev
  4. Compiled PHP
    sudo make




    #Error while doing make install
    # apxs:Error: Activation failed for custom /etc/apache2/httpd.conf file..
    # apxs:Error: At least one `LoadModule' directive already has to exist..


    Noted that: Its a bug in PHP 5.3
    Added this to  /etc/apache2/httpd.conf and the module built correctly.
    # Placeholder for future module installations or else modules will fail to build
    #LoadModule dummy_module /usr/lib/apache2/modules/mod_dummy.so
  5. Stopped any apache2
    sudo /etc/init.d/apache2 stop
    Make install
    sudo /etc/init.d/apache2 start
  6. Write a simple php file index.php with
    <?phpinfo()?>

    and save as  /var/www/index.php
    Now browser should show php info page. If everything is ok, it should show pdo_ibm and ibm_db2 enabled.
DB2 CATALOG Configuration 
  1. Login  DB2 primary account (default is db2insta1).
  2. go to /home/db2insta1/sqllib/bin
    and run ./db2
  3. Register Derby Database server as Node
     db2 catalog tcpip node floreantpos remote 192.168.16.105 server 1527
  4. Register Database in that Node.
    catalog db "posdb" at node posdb authentication server

    NOTE: database  name shoud be same as Floreant POS Derby Database. While doing these steps you must run Derby Database.
    DB2 in Linux does not find Database in smaller case. In case of default database (posdb) we
    just created softlink of database folder and found it working smoothly.

    ln -s posdb POSDB 
  5. Connect database to test
    connect posdb with user name "app" and using sa

    For more visit the following link:
    http://www.ibm.com/developerworks/data/library/techarticle/dm-0409cline2/readme_win.txt

Test with PHP 
         In /var/www/ write a php file to check if it can connect
      
        <?
$database = 'posdb';
$user = 'app';     //derby pass
$password = 'sa'; //your pass
$hostname = '192.168.16.2'; //your IP here
$port = 1527;

$conn_string = $database;


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


if ($conn) {
    echo "Connection succeeded.";
    db2_close($conn);
}
else {
    echo "Connection failed.";
}

?>


Tidak ada komentar:

Posting Komentar