Social Icons

twitterfacebookgoogle pluslinkedinrss feedemail

Pages

Thursday, February 28, 2013

TEIID and nodejs with node-postgres

Ok after a bit of tribulation I managed to access TEIID from nodejs.

It is really simple as the Ramesh's blog stated, but since I had a few problems making it work I try to give a bit of explanation more.

I have TEIID 8.2 on Jboss 7.1.1 and use node v0.8.16 and pg 0.13.1

The code to make connection is:



var pg = require('pg');
var connectionString = "pg://user:user@10.40.1.210:35432/ReportsVDB"
pg.connect(connectionString, function(err, client) {
    if(err){
      console.log(err)
    };
    client.query('SELECT * FROM Reports.reports', function(err, result) {
       if(err){
         console.log(err)
       };
      console.log(result.rows)
    });
});

I have nodejs on Host1 and TEIID on Host2.

The important thing that made me loose a lot of time was that I tried to connect to TEIID on port 31000 that is the default port on JDBC but … the pg protocol goes on ODBC transport

<socket-binding name="teiid-jdbc" port="31000"/>
<socket-binding name="teiid-odbc" port="35432"/>


<transport name="jdbc" socket-binding="teiid-jdbc">
<authentication security-domain="teiid-security"/>
</transport>
<transport name="odbc" socket-binding="teiid-odbc" protocol="pg">
<authentication security-domain="teiid-security"/>
</transport>

So the correct port to use is the ODBC one (just in case you port-offset it)

0 commenti: