简体   繁体   中英

Unable to connect with ClearDB MySQL on Heroku using Node.js

Basically, I have an app deployed on Heroku. Right now, I am trying to connect with ClearDB add-ons but having some weird errors.

Here is my Heroku config :

C:\Users\GDrAnimal\Self-Project\Facebook Bot>heroku config
=== arcane-forest-17003 Config Vars
DATABASE_URL: mysql://b9490a25809735:37eb78b5@us-cdbr-iron-east-05.cleardb.net/heroku_1d0d2358c241fd0?reconnect=true

And here is my code using Nodejs

var mysql = require('mysql');

//Database
var connection = mysql.createConnection({
    host: "us-cdbr-iron-east-05.cleardb.net",
    user: "b9490a25809735",
    password: "37eb78b5"
    database: 'heroku_1d0d2358c241fd0'
});

connection.connect();

app.get('/', (req, res) => {
    connection.query('SELECT * from Student_Bot', function(err, rows, fields) {
        if (err) {
            console.log('Error Reported ', err);
            throw err;
        }
        res.send(['Hello World!!!! HOLA MUNDO!!!!', rows]);
    });
});

However, when I try to open my app, it's crashed ... Here's my Heroku logs :

2017-10-11T03:29:02.994422+00:00 app[web.1]: SyntaxError: Unexpected 
identifier
2017-10-11T03:29:02.994423+00:00 app[web.1]:     at createScript 
(vm.js:56:10)
2017-10-11T03:29:02.994423+00:00 app[web.1]:     at Object.runInThisContext (vm.js:97:10)
2017-10-11T03:29:02.994424+00:00 app[web.1]:     at Module._compile (module.js:542:28)
2017-10-11T03:29:02.994425+00:00 app[web.1]:     at Object.Module._extensions..js (module.js:579:10)
2017-10-11T03:29:02.994426+00:00 app[web.1]:     at Module.load (module.js:487:32)
2017-10-11T03:29:02.994426+00:00 app[web.1]:     at tryModuleLoad (module.js:446:12)
2017-10-11T03:29:02.994427+00:00 app[web.1]:     at Function.Module._load (module.js:438:3)
2017-10-11T03:29:02.994427+00:00 app[web.1]:     at Module.runMain (module.js:604:10)
2017-10-11T03:29:02.994428+00:00 app[web.1]:     at run (bootstrap_node.js:383:7)
2017-10-11T03:29:02.994429+00:00 app[web.1]:     at startup (bootstrap_node.js:149:9)
2017-10-11T03:29:03.094049+00:00 heroku[web.1]: Process exited with status 1
2017-10-11T03:29:03.109659+00:00 heroku[web.1]: State changed from starting to crashed
2017-10-11T03:29:03.113306+00:00 heroku[web.1]: State changed from crashed to starting
2017-10-11T03:29:04.742139+00:00 heroku[web.1]: Starting process with command `node bot.js`
2017-10-11T03:29:07.004884+00:00 app[web.1]: /app/bot.js:27
2017-10-11T03:29:07.004904+00:00 app[web.1]:           database: 'heroku_1d0d2358c241fd0'
2017-10-11T03:29:07.004905+00:00 app[web.1]:           ^^^^^^^^
2017-10-11T03:29:07.004905+00:00 app[web.1]:
2017-10-11T03:29:07.004906+00:00 app[web.1]: SyntaxError: Unexpected identifier
2017-10-11T03:29:07.004907+00:00 app[web.1]:     at createScript (vm.js:56:10)
2017-10-11T03:29:07.004907+00:00 app[web.1]:     at Object.runInThisContext (vm.js:97:10)
2017-10-11T03:29:07.004908+00:00 app[web.1]:     at Module._compile (module.js:542:28)
2017-10-11T03:29:07.004909+00:00 app[web.1]:     at Object.Module._extensions..js (module.js:579:10)
2017-10-11T03:29:07.004909+00:00 app[web.1]:     at Module.load (module.js:487:32)
2017-10-11T03:29:07.004910+00:00 app[web.1]:     at tryModuleLoad (module.js:446:12)
2017-10-11T03:29:07.004910+00:00 app[web.1]:     at Function.Module._load (module.js:438:3)
2017-10-11T03:29:07.004911+00:00 app[web.1]:     at Module.runMain (module.js:604:10)
2017-10-11T03:29:07.004912+00:00 app[web.1]:     at run (bootstrap_node.js:383:7)
2017-10-11T03:29:07.004912+00:00 app[web.1]:     at startup (bootstrap_node.js:149:9)
2017-10-11T03:29:07.086015+00:00 heroku[web.1]: State changed from starting to crashed
2017-10-11T03:29:07.070905+00:00 heroku[web.1]: Process exited with status 1
2017-10-11T04:05:26.000000+00:00 app[api]: Build started by user gdranimal123@gmail.com
2017-10-11T04:05:36.046510+00:00 app[api]: Release v47 created by user gdranimal123@gmail.com
2017-10-11T04:05:36.046510+00:00 app[api]: Deploy 1366f9f3 by user gdranimal123@gmail.com
2017-10-11T04:05:36.525080+00:00 heroku[web.1]: State changed from crashed to starting

You have no comma in your variable man.

 password: "37eb78b5"<missing comma>
database: 'heroku_1d0d2358c241fd0'

Next time you can see the error logs and debug it.

2017-10-11T03:29:07.004884+00:00 app[web.1]: /app/bot.js:27 2017-10-11T03:29:07.004904+00:00 app[web.1]: database: 'heroku_1d0d2358c241fd0'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM