Connect to DB2 database

Connect to DB2 database

SwordmSwordm Posts: 9Questions: 4Answers: 0
edited September 2017 in Free community support

Hello , ı can connect DB2 database with system dsn and this syntax ;

$server="systemdnsfile1"; #the name of the iSeries
$user="user"; 
$pass="pass"; 
$conn=odbc_connect($server,$user,$pass); 

but ı can not establish a PDO connection,
is datatables support connect to different databases ?

, tried this but not works ;

try {
  $connection = new PDO("ibm:YOUR_DSN_NAME", $user, $password, array(
    PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)
  );
}
catch (Exception $e) {
  echo($e->getMessage());
}

Answers

  • allanallan Posts: 63,471Questions: 1Answers: 10,467 Site admin

    Hi,

    I'm afraid that while Editor's PHP libraries do now have db2 support, they use the db2 _* functions in PHP (e.g. db2_connect()) rather than PDO.

    Does your PHP install have the db2 functions available?

    Allan

  • SwordmSwordm Posts: 9Questions: 4Answers: 0

    Hello Allan I can install i think. But main issue is i can only use odbc system dsn to connect database.
    With creating a system dsn at my computer windows then using above connection string i can connect to db2. Is it possible to use it or I have to use db2 functions?

  • allanallan Posts: 63,471Questions: 1Answers: 10,467 Site admin

    If you have to use the odbc functions in PHP you'd need to create another driver for the PHP libraries. Its not really as bad as it sounds though - the DB2 driver could act as a base line - duplicate it and update the methods as needed.

    I've got a few things already going on at the moment, but if I get a chance I'll try setting up a suitable server to test with here.

    Allan

  • SwordmSwordm Posts: 9Questions: 4Answers: 0

    Thanks allan instead of that i ll try to get data with odbc process with json and try client side type.
    If any update on db2 support with odbc I ll follow you

This discussion has been closed.