Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3992236
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T06:44:26+00:00 2026-05-20T06:44:26+00:00

I am developing a large scale application in C++. The application also maintains a

  • 0

I am developing a large scale application in C++. The application also maintains a database (currently I am using MySQL), I use OTL for database connectivity. Now what i want to do is to provide support for using database from multiple vendors. E.g User A use MySQL and user B use PostGres. I think upon implementing it in C++ but didn’t come up with any possible solution due to lack of experience.

What I want to achieve, is something like that:

There would be a separate VC Project that deals with database and suppose it contains following files:

DataAccessLayer.cpp  //This will main entry point of the project
Product.cpp //This deals with product table
Customer.cpp // This deals with Customer table
Orders.cpp //This deals with Orders table
. . . and many more // I want to have one cpp file per Database table`

And we will use the above project in our code like this

DataAccessLayer oDataAccessLayer;
oDataAccessLayer.Connect(); // This will connect to specified database, it might b some abstract class and have concrete class for each supported DB

oDataAccessLayer.Products.Search(//Some parameters here e.g prod id to b search);//I don't want to write search query again again for each database, This function will execute the query in specific database
oDataAccessLayer.Customers.Add(//Parameter)//Same is the case here I don't want to write ADd query for each supported database
oDataAccessLayer.Disconnect();

I don’t want the whole code I just need some sample code or related article to study.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T06:44:26+00:00Added an answer on May 20, 2026 at 6:44 am

    Suppositions:

    Suppose i have following two tables in my database

    1. Project
    2. Docs

    Docs

    And currently i am supporting only following two databases:

    1) Post Gres

    2) Oracle

    Implementation:

    I implement this logic in following three phases

    1) Data Base Adapter: Only this class is exposed to outer world and this contians the Pointer to Each QueryBuilder, these pointer will be initialized in the constructor of this class on the basis of DB type(which is passed as an argument to constructor)

    2) DB Connector: This class will be responsible for DB handling (establish connection, disconnect etc.)

    3) Query Builder: This section contains a basse class for each table in DB and also contains concrete calss for each each specific database

    Sample Code (Synopsis Only)

    DBAdapter.h
    DBAdapter(enum DBType, string ConnectionString);//constructor
    IntializeDBConnectAndQueryBuilder();
    
    Project *pProject;
    Docs *pDocs;
    //----------------------------------------------------------------------------------------
    DBAdapter.cpp
    DBAdapter(enum DBType, string ConnectionString)//constructor
    {
    swithc (DBType)
    {
    case enPostGres:
    pProject = new Project_PostGres();
    pDocs = new Docs_PostGres();
    break;
    
    };
    }
    

    DB Connector Section:

    DBConnector.h
    virtual Connect()=0; //pure virtual
    IsConnected()=0;//pure virtual
    Disconnect()=0; //pure virtual
        //------------------------------------------------------------------------------------------
    DBConnector_PostGres.cpp: DBConnector
    Connect()
    { //Implementation specific to postgres goes here}
    IsConnected()
    { //Implementation specific to postgres goes here}
    Disconnect()
    { //Implementation specific to postgres goes here}
    //------------------------------------------------------------------------------------------
    DBConnector_OracleGres.cpp: DBConnector
    Connect()
    { //Implementation specific to oracle goes here}
    IsConnected()
    { //Implementation specific to oracle goes here}
    Disconnect()
    { //Implementation specific to oracle goes here}
    //------------------------------------------------------------------------------------------
    

    Query Builder Section:

    Project.h
    virtual int AddProject();
    virtual int DeleteProject();
    virtual int IsProjectTableExist();
    
    DBConnector *pDBConnector; // This pointer will be initalized in all concrete classes
    //------------------------------------------------------------------------------------------
    Project.cpp
    int AddProject()
    {
    //Query for adding Project is same for all databases
    }
    
    int DeleteProject()
    {
    //Query for deleting Project is same for all databases
    }
    //------------------------------------------------------------------------------------------
    Project_PostGres.cpp : Project
    Project_PostGres() // Constructor
    {
     pDBConnector = new DBConnector_PostGres();
    }
    
    int IsProjectTableExist()
    {
     //Query specific to postgres goes here
    }
    
    Project
    //------------------------------------------------------------------------------------------
    Project_Oracle.cpp : Project
    {
     //Query specific to oracle goes here
    }
    //. . . and so on for other databases
    //------------------------------------------------------------------------------------------
    
    //Same number of files with same logic will also be created for Docs Table
    
    ------------------------------------------------------------------------------------------
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My team is developing a large java application which extensively queries a MySQL database
I am in the process of developing a large ASP.NET MVC application. I am
I am developing an application to install a large number of data files from
I'm developing an application that gets large images from an Internet server which is
Before I start developing a desktop application, I was wondering how large the installer
I'm about to start developing a large-scale system and I'm struggling with which direction
We are developing large ASP.NET applications with lot of dynmically created pages containing ASCX
I'm developing a website in PHP and I have large JS files that I
I am developing a product with heavy 3D graphics computations, to a large extent
Developing a .NET WinForms application: how can I check if the window is in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.