2016-07-22 58 views
3

我設計了一個使用trireme-jdbc建立opensge數據庫連接的數據層API。當我使用cygwin通過trireme命令運行文件時,代碼運行穩定,但是當我使用命令'a127項目啓動'通過apigeetool啓動完整項目時,它將引發一些有關trireme的錯誤。 我已經使用通用池包進行數據庫連接池與trireme-jdbc.Below是運行我的trireme但不是由a127文件。 這是apigee API,所以文件夾結構完全按照apigee標準進行,並且在此也使用了swagger。如何使用Apigeetool在Apigee上部署Trireme項目

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'); 
}); 
+0

你說「拋出一些錯誤」。你能否提供錯誤的實際文字?另外 - 如果你問一個你知道實際存在的po-num和vend-num會發生什麼? (顯示的SQL似乎可能返回零行。) –

回答

1

我不是一個SQL的傢伙,但它看起來對我來說,你的SQL是無效,或者它沒有返回數據。

我會先用普通的SQL客戶端來測試它。如果您沒有其他設置,Progress會發佈一個名爲「sqlexp」的命令行工具。您應該能夠從服務器的「proenv」窗口運行它,以查看該查詢是否可用。

proenv> sqlexp -user userName -password pwd -db dbName -S port 

我想你可能有更好的運氣編寫SQL爲:

select * from "PUB.po" where "PUB.po.po-num" IS NULL and "PUB.po.vend-num" IS NULL ; 
相關問題