cancel
Showing results for 
Search instead for 
Did you mean: 

Databases for Environments, JDBC Driver Connection String Templates

SOLVED
Highlighted
Occasional Contributor

Databases for Environments, JDBC Driver Connection String Templates

I'm seeing some *odd* things when attempting to add database connections to my project... Here are the details:

  • Mac OS X
  • ReadyAPI 1.7.0
  • Oracle 11g/12c databases
  • OracleThin JDBC driver (located in my \bin\ext directory)

 

I guess I should start with a question....

  1. What is the "correct" way of adding a DB connection to a specific environment? If I want my JDBC request to automatically select a specific DB connection without having to update my test step when switching from dev1 to dev2, how do I do that?
    • My experience so far has been when I add a database connection, it adds it to all my environments.
  2. I need to connect to the DBs via a service name instead of a SID (yes, I've queried the DB and attempted to use the SID, but it doesn't work).  I've modified the DB connection syntax and can connect to the DB, but how do I make the ReadyAPI form ask for a service name instead of a SID?
    • I've attempted to modify the template under Preferences > JDBC drivers, but I just may be using the incorrect format? Notice the slash between the port and the service name....
      • Template: jdbcSmiley Surprisedracle:thin:<USER>/<PASSWORD>@<HOST:127.0.0.1>:<PORT:1521>/<SERVICE_NAME?>
  3. I'm also seeing some oddness when it comes to deleting database connections... I know, a lot of detail here, but just wondering if anyone else is having issues with database connections in general?
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Occasional Contributor

Re: Databases for Environments, JDBC Driver Connection String Templates

Using project level properties worked!  Thanks for the assitance!

 

For reference, I removed all "Databases" from the project.  Below is an example of my JDBC Test Step:

Screen Shot 2016-05-20 at 5.02.35 PM.png

The connection string was cut off in the screenshot, so this is the full line:

jdbcSmiley Surprisedracle:thin:${#Project#dbusername}/${#Project#dbpassword}@${#Project#dbhost}:${#Project#dbport}/${#Project#dbservicename}

 

NOTE:  The "/" after the port number is what tells the driver to connect via a service name instead of the SID.

 

Under environments, populate the values for each property with the environment specific value:

Screen Shot 2016-05-20 at 5.04.59 PM.png

I hope this helps someone in the future!

View solution in original post

2 REPLIES 2
Highlighted
Community Hero

Re: Databases for Environments, JDBC Driver Connection String Templates

I guess you need to use property expansion in the connection string.

Use project properties to define host, port and user credentials.

So, that you can simply modify the property value. When you running commandline, values can be overriden using -P<projectPropertyName>=<value> without even modifying the project.


Regards,
Rao.
Highlighted
Occasional Contributor

Re: Databases for Environments, JDBC Driver Connection String Templates

Using project level properties worked!  Thanks for the assitance!

 

For reference, I removed all "Databases" from the project.  Below is an example of my JDBC Test Step:

Screen Shot 2016-05-20 at 5.02.35 PM.png

The connection string was cut off in the screenshot, so this is the full line:

jdbcSmiley Surprisedracle:thin:${#Project#dbusername}/${#Project#dbpassword}@${#Project#dbhost}:${#Project#dbport}/${#Project#dbservicename}

 

NOTE:  The "/" after the port number is what tells the driver to connect via a service name instead of the SID.

 

Under environments, populate the values for each property with the environment specific value:

Screen Shot 2016-05-20 at 5.04.59 PM.png

I hope this helps someone in the future!

View solution in original post