I am trying to change the connection string dynamically between two different databases (Oracle and Postgres)
So I have a global connection string at project level like below
I am trying to set this connectiong string from groovy script for oracle and postgres by building up the connection string
if(databaseType.contains("postgre"))
{
def postgresConnstring= "jdbc:postgresql://"+databaseHost+":"+databasePort+"/"+databaseUsername+"?user="+databaseUsername+"&password="+databasePassword
testRunner.testCase.testSuite.project.databaseConnectionContainer.getDatabaseConnectionByName('GhixDB').setConnectionString(postgresConnstring)
}
else
if (databaseType.contains("oracle"))
{
def oracleConnString= "jdbc:oracle:thin:"+databaseUsername+"/"+databasePassword+"@"+databaseHost+":"+databasePort+":"+databaseSid
testRunner.testCase.testSuite.project.databaseConnectionContainer.getDatabaseConnectionByName('GhixDB').setConnectionString(oracleConnString)
}
JDBC Connection String for Oracle is something like below. jdbc:oracle:thin:${#Project#databaseUserName}/${#Project#databasePassword}@${#Project#databaseHost}:${#Project#databasePort}:${#Project#databaseSid}
So when I set this connection string at project level i see that the database configuration is picking up part of password and seeting it in the database host field. like below.
I see that the password value gets set to PASS_VALUE when we manually set the connection string. but when I pass some real password value dynamically from script which is more than 10 char long the connection string is picking up the remaining char fro password and passing to the host name.
can someone please help me solve this issue ??