// hello_world.js // RJM Programming // April, 2016 // Node.js Hello World plus starting with MySql local web server work // Thanks to: // https://nodejs.org/en/download/ // http://expressjs.com/en/starter/installing.html // https://codeforgeek.com/2015/01/nodejs-mysql-tutorial/ // http://stackoverflow.com/questions/18134411/cannot-find-module-mysql-node-js // http://stackoverflow.com/questions/30266221/node-js-mysql-error-connect-econnrefused // http://www.infoworld.com/article/2866712/php/php-vs-node-js-an-epic-battle-for-developer-mind-share.html var express = require('express'); var app = express(); app.get('/', function (req, res) { res.send('Hello World!'); }); var mysql = require('mysql'); var connection = mysql.createConnection({ host : 'localhost', user : 'root', password : 'root', database : 'testdb', socketPath: '/Applications/MAMP/tmp/mysql/mysql.sock' }); connection.connect(); connection.query('SELECT * from CIRCLE, POINT WHERE pointid=originid', function(err, rows, fields) { if (err) throw err; if (!err) console.log('The solution is: ', rows); else console.log('Error while performing Query.'); }); connection.end(); app.listen(3000, function () { console.log('Example app listening on port 3000!'); });