输入banner图图片脚本导航/分类

nodejs链接mysql 中的问题


可以集中连接以简化共享单个连接或管理多个连接。
当你完成一个连接时,只需调用connection.release(),连接将返回到池中,准备再次被其他使用。
var mysql = require(‘mysql‘);
var pool  = mysql.createPool({
  host     : ‘example.org‘,
  user     : ‘bob‘,
  password : ‘secret‘,
  database : ‘my_db‘
});

pool.getConnection(function(err, connection) {
  // Use the connection
  connection.query(‘SELECT something FROM sometable‘, function (error, results, fields) {
    // And done with the connection.
    connection.release();

    // Handle error after the release.
    if (error) throw error;

    // Don‘t use the connection here, it has been returned to the pool.
  });
});

特别要注意语法。

 
 

 

nodejs链接mysql 中的问题

标签:blog   sel   准备   func   搜索   data-   分享图片   word   info