Reputation: 363
I have design a data layer API to establish openedge database connection using trireme-jdbc. The code is working solid when I am running the file by trireme command using cygwin, but when I start the complete project through apigeetool using command 'a127 project start' then it throws some error regarding trireme. I have used generic-pool package for database connection pooling along with trireme-jdbc.Below is the file that is running my trireme but not by a127. This is a apigee API so folder structure is totally as per apigee standard and swagger is also used here.
var a127 = require('a127-magic');
var express = require('express');
var Pool = require('generic-pool').Pool;
var jdbc = require('trireme-jdbc');
var app = express();
module.exports = app; // for testing
// initialize a127 framework
a127.init(function(config) {
// include a127 middleware
app.use(a127.middleware(config));
var pool = new Pool(
{
name : 'Suppllier Collaboration - @Anil',
create : function(callback) {
var connOpenedge = new jdbc.Database(
{
url : 'jdbc:datadirect:openedge://serverhost:portno;DatabaseName=xxxxx',
properties : {
user : 'db_user',
password : 'db_password',
},
});
callback(null, connOpenedge);
},
destroy : function(client) {
client.end();
},
max : 10,
min : 2,
idleTimeoutMillis : 30,
log : true
});
// error handler to emit errors as a json string
app.use(function(err, req, res, next) {
console.log('we are just enter in app.js file');
if (typeof err !== 'object') {
// If the object is not an Error, create a representation that appears to be
err = {
message: String(err) // Coerce to string
};
} else {
// Ensure that err.message is enumerable (It is not by default)
Object.defineProperty(err, 'message', { enumerable: true });
}
// Return a JSON representation of #/definitions/ErrorResponse
res.set('Content-Type', 'application/json');
res.end(JSON.stringify(err));
});
pool.acquire(function(err, conn) {
if (err) {
throw err;
} else {
app.get("/getData", function(req, res) {
conn.execute('select * from "po" where "po-num" = ? and "vend-num" = ? ',
[4322452, 4301170 ], function(err, result, rows) {
if (err)
res.json("Sorry !Error to get data from symix....");
else
res.json(rows);
});
});
}
});
var ip = process.env.IP || 'localhost';
var port = process.env.PORT || 10010;
// begin listening for client requests
app.listen(port, ip);
console.log('we are inside app.js file');
console.log('try this:\ncurl http://' + ip + ':' + port + '/hello?name=Scott');
});
Upvotes: 3
Views: 164
Reputation: 14020
I am not a SQL guy but it looks to me like your SQL is either not valid or it returns no data.
I would first test it using a plain SQL client. Progress ships a command line tool called "sqlexp" if you don't have anything else setup. You should be able to run it from a "proenv" window in the server to see if that query works at all.
proenv> sqlexp -user userName -password pwd -db dbName -S port
And I think you might have better luck writing that SQL as:
select * from "PUB.po" where "PUB.po.po-num" IS NULL and "PUB.po.vend-num" IS NULL ;
Upvotes: 1