当前位置 : 主页 > 网络编程 > JavaScript >

express连接orcale

来源:互联网 收集:自由互联 发布时间:2021-06-30
gistfile1.txt var express = require('express');var router = express.Router();var oracledb = require('oracledb');/* GET home page. */router.get('/', function(req, res, next) { // res.render('index', { title: 'Express' }); oracledb.getConnect
gistfile1.txt
var express = require('express');
var router = express.Router();
var oracledb = require('oracledb');
/* GET home page. */
router.get('/', function(req, res, next) {
  // res.render('index', { title: 'Express' });
  oracledb.getConnection({
        user: 'cs',
        password: '123456',
        connectString: 'localhost/orcl'
    },
    function(err,connection){
      if(err){
          console.error(err.message);
          return;
      }
      connection.execute(
          "SELECT * " +
            "FROM OBJ_LOC_TABLE " +
            "WHERE OBJ_ID = :id",
          [1],
          function(err, result)
          {
            if (err) {
              console.error(err.message);
              doRelease(connection);
              return;
            }
            console.log(result.metaData); 
            console.log(result.rows);   
            var longitude = result.rows[0][1];
            var latitude = result.rows[0][2];
            console.log(longitude);
            console.log(latitude) ;
            res.render('index', { title: longitude});
          });
    }
  );

  //  res.render('map');
  // res.render('index', { title: longitude});
 
});

module.exports = router;
网友评论