Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2015
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // https://github.com/felixge/node-mysql/
  2.  
  3. var query = "select sleep(1), id from blog_post limit 1;"
  4.  
  5. var mysql      = require('mysql');
  6.  
  7. var pool  = mysql.createPool({
  8.   connectionLimit : 100,
  9.   host     : 'localhost',
  10.   user     : 'root',
  11.   password : '123',
  12.   database : 'kodoman',
  13. });
  14.  
  15. for (var i=0; i<100; ++i) {
  16.     pool.query(query, function(err, rows, fields) {
  17.       if (err) throw err;
  18.  
  19.       console.log(rows);
  20.     });
  21. }
  22.  
  23. setTimeout(function () {
  24. pool.end(function (err) {
  25.   // all connections in the pool have ended
  26. });
  27. }, 2100)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement