Home IT Linux Windows Database Network Programming Server Mobile  
  Home \ Programming \ Nodejs mysql pool Example     - The difference between equals and == in Java (Programming)

- Ubuntu installed Komodo editor by PPA (Linux)

- Binary search -Java achieve (Programming)

- Linux FAQ - How to fix tar:Exitingwith failure status due to previous errors (Linux)

- General Linux interface server parameter tuning (Server)

- Golang use Oracle database on Ubuntu 14.04 (Linux)

- xCAT install and update software (Linux)

- OpenSSH server configuration file for each Common Definition (Server)

- To repair Shell script by default open in Ubuntu (Linux)

- Implement Oracle dynamic registration of non-standard port 1521 (Database)

- Windows7 / 8 / 8.1 hard drive to install Ubuntu 14.04 dual system (Linux)

- Nmcli based network management command-line tool (Linux)

- Redis configuration file interpretation (Database)

- Snapshot DataGuard (Database)

- SolrCloud-5.2.1 cluster deployment and testing (Server)

- Port Telnet command to detect the remote host is turned on (Linux)

- SSH does not require a password to log on to a Linux server (Server)

- Debugging with GDB tool Go (Programming)

- Ubuntu arm-none-eabi-gcc compiler treated with STM32F10x (Linux)

- Introduction and use of the Raspberry Pi (Linux)

  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;
- Systemd on RHEL7 (Linux)
- How to install CentOS CentOS web page (Server)
- Python image processing library (PIL) to install and simple to use (Linux)
- Ten best plug surge Emacs Productivity (Linux)
- Get the Linux device PCI ID method (Linux)
- Based shell: using read, the command-line script to achieve mass participation and input two integer calculation (Programming)
- Depth understanding of DB2 table space (Tablespace) (Database)
- Overall Physical Migration of Oracle Database with (Database)
- Running into the site-wide HTTPS (Server)
- Linux system monitoring, top command of the diagnostic tool Detailed (Linux)
- Installation salt-minion on RHEL5 (Linux)
- JavaScript closures and the scope chain (Programming)
- Installed FFmpeg 2.6.3 on Ubuntu / Debian / Fedora system (Linux)
- CentOS yum source deployment (Linux)
- linux server security (Linux)
- Vim useful plugin: EasyGrep (Linux)
- VMware Workstation + Ubuntu 10.04 Download the Android 2.2 source code (Linux)
- Linux regex awk Comments (Linux)
- Linux System Getting Started Learning: The Linux log (Linux)
- How to release the cache memory on Linux (Linux)
  CopyRight 2002-2016 newfreesoft.com, All Rights Reserved.