How Can We Help?
< All Topics
Print

Database Connection Strings

All instances, created in BitssCloud, are operated as independent containers. To establish the connection to a database from the application, deployed within an 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).

1. Database Connection for Java Application:

DB typesConnection Code 
MySQL / MariaDB String URL = “jdbc:mysql://node{node_id}-{environment_name}.{hoster_domain}/{dbname}”;DriverManager.getConnection(URL, user_name,user_password);
MySQLAuto-ClusterString URL = “jdbc:mysql://proxy.{environment_name}.{hoster_domain}:3306/{dbname}”;DriverManager.getConnection(URL, user_name,user_password);
MariaDBAuto-ClusterString URL = “jdbc:mariadb://proxy.{environment_name}.{hoster_domain}:3306/{dbname}?usePipelineAuth=false“;DriverManager.getConnection(URL, user_name,user_password);
PostgreSQLString URL = “jdbc:postgresql://node{node_id}-{environment_name}.{hoster_domain}/{dbname}”;DriverManager.getConnection(URL, user_name,user_password);
MongoDBMongo 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!”);}

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”

2. Database Connection for PHP Application:

DB typesConnection Code 
MariaDB and MySQL mysql_connect(‘HOST’, ‘USERNAME’, ‘PASSWORD’)
MongoDBMongo(“hostaddress”, array(“username” => “username”, “password” => “password”))
PostgreSQLpg_connect(“host=host_address port=5432 dbname=postgres user=webadmin password=password”)

Table of Contents