Connect your app with the ClearDB database
1. Once you have created clearDB for your database, we can now connect our app with the ClearDB database. Refer to the top of your Heroku application page, in the menu section, click Settings.
2. Arriving at the Settings page, find the Config Vars (configurations variables) section below the application information. Then click Reveal Config Vars to show the details
3. Sometimes configuration variables can be links and are too long for the section bar. Find the configuration that says CLEARDB_DATABASE_URL, and click the pencil icon on the right to open up more details on the configuration.
4. After you open up the details, you should see the contents of your CLEARDB_DATABASE_URL value
The value in red circle, represents user
The value in blue circle, represents password
The value in green circle, represents host
The value in black circle, represents database
5. Using those values, you can set up your connection to the ClearDB database in your web application. Here is an example in Javascript, each above value will be set as a string to its corresponding key.
const dbConfigHeroku = {
host: "us-cdbr-east-02.cleardb.com",
user: "b929a931850c68",
password: "c8e4edf7",
database: "heroku_af1c36b63c9aac7",
multipleStatements: false,
reconnect: true
};
Conclusion: Following the steps of this configuration tutorial, now your web application will be able to connect to the ClearDB database.