Check for connection errors:
connection.connect(function(err) {
console.log(err.code); // 'ECONNREFUSED'
console.log(err.fatal); // true});
On Thu, Jan 23, 2014 at 6:15 AM, pitambar patra <[email protected]>wrote:
> i am new to node.js ,so trying to read/write to database, but
> i am getting the error while compiling my sql1.js file
>
> sql1.js -->
> var mysql = require('mysql');
> var connection = mysql.createConnection({
> host : 'localhost',
> user : 'me',
> password : 'secret'
> });
>
> connection.connect();
>
> connection.query('SELECT 1 + 1 AS solution', function(err, rows, fields) {
> if (err) throw err;
>
> console.log('The solution is: ', rows[0].solution);
> });
>
> connection.end();
> below is the log
>
> pitambar@pitambar-TravelMate-4740:~/node-example/hands-on-node.js$ npm ls
> installed
> [email protected] active installed
> [email protected] active installed
> [email protected] active installed
> [email protected] active installed
> [email protected] active installed
> [email protected] active installed
> [email protected] active installed
> *[email protected] active installed *
> [email protected] active installed
> [email protected] active installed
> [email protected] active installed
> [email protected] active installed
> npm ok
> pitambar@pitambar-TravelMate-4740:~/node-example/hands-on-node.js$ node
> sql1.js
>
> node.js:134
> throw e; // process.nextTick error, or 'error' event on first tick
> ^
>
> *TypeError: Object prototype may only be an Object or null at
> Function.create (native)*
> at Object.inherits (util.js:425:27)
> at Object.<anonymous>
> (/home/pitambar/.node_libraries/.npm/readable-stream/1.1.10/package/lib/_stream_readable.js:55:6)
> at Module._compile (module.js:402:26)
> at Object..js (module.js:408:10)
> at Module.load (module.js:334:31)
> at Function._load (module.js:293:12)
> at require (module.js:346:19)
> at Object.<anonymous>
> (/home/pitambar/.node_libraries/.npm/readable-stream/1.1.10/package/readable.js:1:90)
> at Module._compile (module.js:402:26)
> pitambar@pitambar-TravelMate-4740:~/node-example/hands-on-node.js$ ^C
> pitambar@pitambar-TravelMate-4740:~/node-example/hands-on-node.js$
>
> what to do in such case,i have googled it but no use,
> thank you
>
> --
> --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
>
> ---
> You received this message because you are subscribed to the Google Groups
> "nodejs" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>
--
--
Job Board: http://jobs.nodejs.org/
Posting guidelines:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.