Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Programming \ Nodejs mysql pool Example     - Taught you how to install Ubuntu Linux (Linux)

- Features and prevention methods elaborate network security grayware (Linux)

- How to create a someone project on github (Linux)

- To upgrade combat MongoDB database replication sets and split versions (Database)

- Jump table (skiplist) of code (Programming)

- Redis Linux system installation guide (Database)

- Ubuntu 15.04 / CentOS 7.0 to set custom boot (Linux)

- CentOS 6.5 system installation Oracle11.2.0.4 basic steps (Database)

- Linux and hardware (Linux)

- By creating a personal technology blog Detailed GitHub (Linux)

- How LUKS encrypted disk / partition to perform remote incremental backup (Linux)

- Ubuntu 14.10 / 14.04 how to install Quick Start tool Mutate 2.2 (Linux)

- Machine Learning: Classification of the curse of dimensionality (Programming)

- W and uptime command (Linux)

- Firewall types and instructions (Linux)

- Mac OS X command line to submit the local project to Git (Server)

- innodb storage engine backup tool --Xtrabackup (Database)

- JavaScript, some conclusions about the implicit conversion (Programming)

- Using Oracle for Oracle GoldenGate to achieve a one-way data synchronization (Database)

- Zabbix configuration of SNMP (Server)

 
         
  Nodejs mysql pool Example
     
  Add Date : 2018-11-21      
         
         
         
  Some time ago to write a version of the publishing tool used to achieve express + mysql, when the site is running for a long period of blank time, node process automatically fall down, suggesting a connection error mysql, mysql is found after Google's own characteristics lead, so later mysql pool even to solve the problem once!

mysql module felixge / node-mysql

Source code as follows:

var express = require ( 'express');
var router = express.Router ();
var mysql = require ( 'mysql');
var conf = require ( '../ config / dbconnection');

// Define pool pool
var pool = mysql.createPool (
    {
        host: conf.dbMysql.host,
        user: conf.dbMysql.user,
        password: conf.dbMysql.password,
        database: conf.dbMysql.database,
        port: conf.dbMysql.port
    }
);

router.get ( '/', function (req, res) {
    var selectSites = "select *, date_format (do_time, '% Y-% m-% d% H:% i:% s') as time from siteinfo order by id";
    pool.getConnection (function (err, connection) {
        if (err) throw err;
        connection.query (selectSites, function (err, rows) {
            if (err) throw err;
            res.render ( 'sites', {title: 'site distribution', results: rows})
        });
        // Recovery pool
        connection.release ();
    });
});

module.exports = router;
     
         
         
         
  More:      
 
- Ubuntu and derived versions of the user how to install G Mic 1.5.8.5 (Linux)
- How to use static, class, abstract method in Python (Programming)
- RedHat Linux 6.5 Enterprise Edition installation Redis 3.0.3 (Database)
- Linux Getting Started tutorial: GNU C and Vim will fight the C / C ++ IDE semi-automatic (Linux)
- Oracle table space usage monitoring (Database)
- MySQL master-slave delay problem (Database)
- Ubuntu 14.04 virtual machine switching desktop environments (Linux)
- Python kills corresponding process according to pid (Programming)
- Fedora 20 users install the Mate 1.8 desktop (Linux)
- Linux Variable content removal and replacement (Linux)
- Process safety monitoring and protection under the Linux operating system (Linux)
- Linux boot process (Linux)
- MySQL master recovery from failure using binlog (Database)
- Linux into single user mode to modify the administrator password (Linux)
- namespace mechanism Linux kernel analysis (Linux)
- To configure Samba to share files with Windows under CentOS (Linux)
- Java call by value and by reference (Programming)
- Linux / Unix: chroot command examples to explain (Linux)
- Linux command find (Linux)
- mydumper installation error process (Database)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.