Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- con.query('SELECT * FROM country ',function(err,rows){
- if(err) throw err;
- console.log('Data received from Db:n');
- console.log(rows);
- });
- GET http://localhost:3000/item/create 500 (Internal Server Error)
- var con = mysql.createConnection({
- host: "127.0.0.1",
- port: "3306",
- user: "root",
- password: "",
- database: "myDataBase",
- });
- var con = mysql.createConnection({
- host : MYSQL_DB_HOST,
- user : MYSQL_DB_USER,
- password : MYSQL_DB_PWD,
- database : MYSQL_DB_NAME
- });
- con.connect(function(err) {
- if(err) {
- console.log('con : error when connecting to db : ', err);
- setTimeout(/*create again */, 2000);
- }
- else {
- console.log('Connected ');
- }
- });
- con.on('error', function(err) {
- console.log('con : db error : ', err);
- if(err.code === 'PROTOCOL_CONNECTION_LOST') {
- //Create Again
- }
- else {
- throw err;
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement