Forum Discussion

markgholland's avatar
markgholland
Occasional Contributor
8 years ago
Solved

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: jdbc:oracle: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?
  • 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:

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

    jdbc:oracle: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:

    I hope this helps someone in the future!

2 Replies

  • nmrao's avatar
    nmrao
    Champion Level 3
    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.
    • markgholland's avatar
      markgholland
      Occasional Contributor

      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:

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

      jdbc:oracle: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:

      I hope this helps someone in the future!