0

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 enter image description here

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.

enter image description here

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 ??

mo0206
  • 791
  • 5
  • 20
  • 36
  • Please see if [this](http://stackoverflow.com/questions/37655778/soapui-ability-to-switch-between-database-connections-for-test-suite/37659250#37659250) approach help you to have better control to switch between databases. – Rao Jun 23 '16 at 00:32
  • @Rao The solution mentioned is when we have one database type. But I have two different database types oracle and Postgres. The connection string is different for both the databases. – mo0206 Jun 23 '16 at 16:57
  • You still can use it provided if you can add an addition property for `Driver Class` as well. – Rao Jun 23 '16 at 16:58
  • The connection string is different for both the databases. So changing the driver alone would not work. – mo0206 Jun 23 '16 at 17:09
  • Well, one more property to externalise it. – Rao Jun 23 '16 at 17:09
  • if I externalize the connection string property, a part of the password is being picked up by the host field .. since password value is usually renamed to PASS_VALUE in the connection string.. when i pass the actual value,, part of the password after 10 char is picked by host,, which is shown in the snapshot that I have attached in the question... – mo0206 Jun 23 '16 at 17:18
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/115434/discussion-between-monica-thaneer-and-rao). – mo0206 Jun 23 '16 at 17:23
  • Is it still a problem? Did you make any changes based on the chat discussion? – Rao Jun 26 '16 at 16:57

0 Answers0