2015-10-03 47 views
0

我想连接到池模块,但它没有连接。 下面是我的代码:无法连接到池模块

var express = require('express') 
    , routes = require('./routes') 
    , signup = require('./routes/signup') 
    ,login=require('./routes/login') 
    , http = require('http') 
    , path = require('path') 
    , cal=require('./routes/calculate') 
    , db = require('./routes/db') 
     ,pool = require('./routes/pooling') 
     , ejs = require('ejs') 
    , moment = require('moment') 
    , mysql = require('mysql') 
    ; 

     var app = express(); 

     pool.connect(); 
     pool.initializepool(10); 

我得到以下错误:

找不到模块./routes/pooling。

我想实现连接池。 有人可以帮我吗?

回答

0

请参阅mysql模块自述文件中的合并示例。删除池的需求(不需要而不是路由)。

var pool = mysql.createPool({ 
    connectionLimit : 10, 
    host   : 'example.org', 
    user   : 'bob', 
    password  : 'secret' 
}); 

pool.query('SELECT 1 + 1 AS solution', function(err, rows, fields) { 
    if (err) throw err; 

    console.log('The solution is: ', rows[0].solution); 
});