Apache Ignite - [PDOException] SQLSTATE[IM002] SQL

2019-09-05 04:08发布

问题:

I have setup apache ignite, loaded data into ignite from Java app and can query using rest apis. I need to query it from PHP so

I am trying to connect to Apache Ignite from PHP using pdo_odbc. I have,

i) Installed ODBC driver manager - http://www.unixodbc.org/

ii) Built ODBC driver http://apacheignite.gridgain.org/docs/odbc-driver#section-building-on-linux

iii) installed Ignite ODBC driver http://apacheignite.gridgain.org/docs/odbc-driver#section-installing-on-linux,

iv) configured dsn, http://apacheignite.gridgain.org/v1.8/docs/connecting-string#configuring-dsn using

odbcinst -j

unixODBC 2.3.4
DRIVERS............: /etc/odbcinst.ini
SYSTEM DATA SOURCES: /etc/odbc.ini
FILE DATA SOURCES..: /etc/ODBCDataSources
USER DATA SOURCES..: /home/me/.odbc.ini
SQLULEN Size.......: 8
SQLLEN Size........: 8
SQLSETPOSIROW Size.: 8

cat /etc/odbcinst.ini

[Apache Ignite]
Description=Apache Ignite
Driver=/usr/local/lib/libignite-odbc.so
DriverODBCVer=03.00
FileUsage=0
UsageCount=1

cat /etc/odbc.ini

[Apache Ignite]
Description=Apache Ignite
Driver=/usr/local/lib/libignite-odbc.so
DriverODBCVer=03.00
FileUsage=0
UsageCount=1

cat /home/me/.odbc.ini

[Apache Ignite]
Description=Apache Ignite
Driver=/usr/local/lib/libignite-odbc.so
DriverODBCVer=03.00
FileUsage=0
UsageCount=1

v) installed pdo_odbc,

sudo apt install php5.6-odbc

It shows in phpinfo.

vi) enabled OdbcConfiguration using

Ignite ignite = Ignition.start("examples/config/example-ignite.xml");
IgniteConfiguration iCfg = ignite.configuration();
OdbcConfiguration odbcCfg = new OdbcConfiguration();
iCfg.setOdbcConfiguration(odbcCfg);

vii)

$ignite = $dbh = new \PDO('odbc:Apache Ignite');
$ignite->prepare('select * from Person');

I am still getting this exception.

  [PDOException]                                                                                                              
  SQLSTATE[01000] SQLConnect: 0 [unixODBC][Driver Manager]Can't open lib '/usr/local/lib/libignite-odbc.so' : file not found 

Update: LD_LIBRARY_PATH already has /usr/local/lib ls /usr/local/lib | grep libignite-binary-1.8.0.16166.so.0

libignite-binary-1.8.0.16166.so.0
libignite-binary-1.8.0.16166.so.0.0.0

ldd /usr/local/lib/libignite-odbc.so

linux-vdso.so.1 => (0x00007ffe68521000) libignite-binary-1.8.0.16166.so.0 => not found

回答1:

Have you tried run ldd /usr/local/lib/libignite-odbc.so? It seems like there are some unresolved dependencies. Maybe you need to add them to LD_LIBRARY_PATH.