- CNAME of database, eg. {mysql}-{environment_name}.{hoster_domain}
- Private IP address
- Public IP address, in case you purchased it
Note: you cannot establish connection from application to database specifying localhost as a connection string.
When you create a new environment which includes a database server (MySQL, MariaDB, PostgreSQL, MongoDB, CouchDB), Jelastic sends you an email with ROOT login and password to the database Administrative console.
To get to the database administrative console:
- Type the following URL in your browser:
{dbtype}-{environment-name}.{hoster_domain} - Or, in Jelastic dashboard (app.{hoster_domain}), expand the environment and click Open in Browser button next to the database.
Use the credentials you received on email to log in to the database administrative panel, then create the databases and user accounts that your application needs.
In your Java application you would likely have the database connection code similar to the one below: - MySQL
| Database | string in URL - {dbtype} |
| MySQL | mysql |
| MariaDB | mariadb |
| PostgreSQL | postgres |
| MongoDB | mongodb |
| CouchDB | couchdb |
String URL = "jdbc:mysql://mysql-{your-environment-name}.{hoster_domain}/{dbname}";
DriverManager.getConnection(URL, user_name,user_password);
String URL = "jdbc:mysql://mariadb-{your-environment-name}.{hoster_domain}/{dbname}";
DriverManager.getConnection(URL, user_name,user_password);
String URL = "jdbc:postgresql://postgres-{your-environment-name}.{hoster_domain}/{dbname}";
DriverManager.getConnection(URL, user_name,user_password);
Mongo m = new Mongo(mongodb-{your-environment-name}.{hoster_domain});
DB db = m.getDB({data-base-name});
if (db.authenticate(user_name,user_password.toCharArray())) {
System.out.println("Connected!");
}
String host = "couchdb-{your-environment-name}.{hoster_domain}";
int port = 80;
String username = "username";
String password = "password";
Session dbSession = new Session(host, port, username, password);
For UTF-8 encoding, modify your connection string to this:
"jdbc:{dbtype}://{dbtype}-{your-environment-name}.{hoster_domain}/{dbname}?useUnicode=yes&characterEncoding=UTF-8"
The information on your hoster domain you can find in the document Hosters Info (last column in the first table).