Database Connection Strings

All instances, created inside the platform, are operated as independent containers. To establish connection to a database from the application, deployed within application server, you need to set a connection string for it, using either:

  • CNAME of database, e.g. node{node_id}-{environment_name}.{hoster_domain}
  • Private IP address
  • Public IP address (if attached)
Note: Specifying localhost within a connection string will not work for establishing connection between application and database.

Depending on the engine that powers your environment, refer to one of the sections below:

  • Java
  • PHP

Look through the table of database types to find the appropriate DB connection code for your application:

DB Type Connection code
MySQL/MariaDB String URL = “jdbc:mysql://node{node_id}-{environment_name}.{hoster_domain}/{dbname}";DriverManager.getConnection(URL, user_name,user_password);
MySQL Auto-Cluster Highly available connection via the scaled dedicated ProxySQL load balancers.
String URL = “jdbc:mysql://proxy.{environment_name} .{hoster_domain}:3306/{dbname}"; DriverManager.getConnection(URL, user_name,user_password);
MariaDB Auto-Cluster Highly available connection via the scaled dedicated ProxySQL load balancers.
String URL = “jdbc:mariadb://proxy.{environment_name} .{hoster_domain}:3306/{dbname}?usePipelineAuth=false"; DriverManager.getConnection(URL, user_name,user_password);
PostgreSQL String URL = “jdbc:postgresql://node{node_id}-{environment_name}.{hoster_domain}/{dbname}"; DriverManager.getConnection(URL, user_name,user_password);
MongoDB Mongo m = new Mongo(node{node_id}-{environment_name}.{hoster_domain}); DB db = m.getDB ({database_name}); if(db.authenticate(user_name,user_password.toCharArray())) { System.out.println(“Connected!"); }
CouchDB String host = “node{node_id}-{environment_name}.{hoster_domain}"; int port = 80; String username = “username”; String password = “password”; Session dbSession = new Session(host, port, username, password);

For the UTF-8 encoding, modify your connection string according to this:

“jdbc:{dbtype}://{dbtype}{node_id}-{environment_name}.{hoster_domain}/{dbname}?useUnicode=yes&characterEncoding=UTF-8”

In case your hosting provider platform has several environment regions to choose, the {hoster_domain} value for your environment can differ from the general platform’s one.

Based on the used DB type, check out the connection code examples below and adjust your application appropriately:

DB Type Connection code
MySQL and MariaDB mysql_connect(‘HOST’, ‘USERNAME’, ‘PASSWORD’)
MongoDB Mongo(“hostaddress”, array(“username” => “username”, “password” => “password”))
PostgreSQL pg_connect(“host=host_address port=5432 dbname=postgres user=webadmin password=password”)
Note: It is required to specify the host string without http://. The appropriate address and credentials are located in the email you’ve received upon database creation.
Was this answer helpful? 0 Users Found This Useful (0 Votes)