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

  • SEARCH
  • Home
  • 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

I'm developing a web application based on ASP.NET MVC. There are a large database.
I am developing a Java application using Google App Engine that depends on a
Background I am developing an application for android in eclipse and now I have
I'm developing a rather large XML Schema to integrate multiple disparate systems. Each system
I'm currently developing a machine learning toolkit for GPU clusters. I tested logistic regression
I am developing a Flex application in which I would like to simulate roughly
I am developing a website which needs to contain functionality in which the user
Greetings, I am developing a web app. One piece of it will allow users
I'm developing a simple protocol that is used to read/write integer values from/to a
The widget design guidelines provide the standard widget sizes for your medium sized screen.

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.