Advertisement
Guest User

Untitled

a guest
Jan 14th, 2016
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. con.query('SELECT * FROM country ',function(err,rows){
  2. if(err) throw err;
  3. console.log('Data received from Db:n');
  4. console.log(rows);
  5. });
  6.  
  7. GET http://localhost:3000/item/create 500 (Internal Server Error)
  8.  
  9. var con = mysql.createConnection({
  10. host: "127.0.0.1",
  11. port: "3306",
  12. user: "root",
  13. password: "",
  14. database: "myDataBase",
  15. });
  16.  
  17. var con = mysql.createConnection({
  18. host : MYSQL_DB_HOST,
  19. user : MYSQL_DB_USER,
  20. password : MYSQL_DB_PWD,
  21. database : MYSQL_DB_NAME
  22. });
  23.  
  24. con.connect(function(err) {
  25. if(err) {
  26. console.log('con : error when connecting to db : ', err);
  27. setTimeout(/*create again */, 2000);
  28. }
  29. else {
  30. console.log('Connected ');
  31. }
  32. });
  33.  
  34. con.on('error', function(err) {
  35. console.log('con : db error : ', err);
  36. if(err.code === 'PROTOCOL_CONNECTION_LOST') {
  37. //Create Again
  38. }
  39. else {
  40. throw err;
  41. }
  42. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement