Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Image RemovedImage Removed

...

  • Navigate to SETTINGS → DATA SOURCES

...

  • Select your Database and click SETUP

...

  • SAVE your DB connection strings.

Image Added

  • Use the connection with in your Code.

Expand
titleJAVASCRIPT Usage

Code Block
languagejs
const { DB } = require('../setup/database-connector');
 
  before(async function () {
    connection = await DB.mySqlConnection(
      process.env.db_host,
      process.env.db_user,
      process.env.db_password,
      process.env.db_name
    );
    // await driverHelper.getDriver((connector) => {
    //   driver = connector;
    // });
  });
  
   it('Step_16624', async function () {
    connection.connect((err) => {
      if (err) console.log(err);
      console.log('connection successfuly');
    });
  });

Expand
titleJAVA Usage

Code Block
languagejava
import java.sql.Connection;

public void BeforeAll() throws MalformedURLException, Exception {
        driver = DriverManager.CreateDriver();
        _connection = DatabaseConnector.GetMySqlConnection(System.getenv("db_host"),
                System.getenv("db_user"),
                System.getenv("db_password"),
                System.getenv("db_name")
                );
    }

Expand
titleC# Usage
Code Block
languagec#
private MySqlConnection _connection;

_connection = DatabaseConnector.CreateMysqlConnection(
                Environment.GetEnvironmentVariable("db_host"),
                Environment.GetEnvironmentVariable("db_user"),
                Environment.GetEnvironmentVariable("db_password"),
                Environment.GetEnvironmentVariable("db_name")
            );