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 8843779
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:19:05+00:00 2026-06-14T11:19:05+00:00

I have 2 databases old & new , old db detail needs to be

  • 0

I have 2 databases old & new, old db detail needs to be filtered/manipulated and stored into new.

OLD DB

  1. I have around 10000 configurations (DB rows)

  2. and 10000 BLOBS (xml file size is 4MB on an average) matching config id’s from above

NEW DB

  1. 1 new table that is going to contain the filtered data from old, but this time no BLOB data, instead absolute paths

  2. and per configuration some recommendations

Here I wrote a program (using Groovy & MyBatis for DB) which gets all the configuration records available in OLD DB and stores in a List of class and the DB Connection is closed

In order to fetch the BLOBS too for each config id, a new connection is established & is kept open for a long time

List<String> projectid
List<CSMConfigInfo> oldConfigs
List<ConfigInfo> newConfigs 
Map<String,CSMConfigInfo> oldConfigMap

SqlSession session = DatabaseConnectivity.getOldCSMDBSessionFactory().openSession()
/*  trying to batch execute based on project id */
    projectid.each {pid->
        logger.info "Initiating conversion for all configuration under $pid project id"
        oldConfigMap.each {k,v->
/*  Here I am keeping a DB connection open for a long time */           
            if(pid.equals(v)){                  
                createFromBlob(k,session)                   
            }
        }                       
        logger.info "Completed for $pid project id\n"           
    }

session.close()

After fetching the BLOB 1 by 1, I create a temp xml file which is parsed to apply the filter for inserting into NEW DB. Below code you can see that based on whether xml is convertible and parsible a new connection is opened for NEW DB. Is this good practice or do I need to keep the NEW DB connection open for all 10000 records?

/* XML is converted to new format and is parsable */
def createFromBlob(CSMConfigInfo cfg,SqlSession oldCSMSession){
    .
    .

    if(xmlConverted&&xmlParsed){
        //DB Entries
        try{
            /* So now here I am opening a new connection for every old config record, which can be 10000 times too, depending on the filter */
            SqlSession sess = DatabaseConnectivity.getNewCSMSessionFactory().openSession()

            //New CSM Config
            makeDatabaseEntriesForConfiguration(newConfig,sess)
            //Fire Rules
            fireRules(newConfig,sess,newCSMRoot)

            sess.close()

        }
        catch(IOException e){
            logger.info "Exception with ${newConfig.getCfgId().toString()} while making DB entries for CONFIG_INFO"
        }
        logger.info "Config id: "+cfg.getCfgId().toString()+" completed successfully, took "+getElapsedTime(startTime)+ " time. $newabspath"
    }
    else{
        def errormsg = null
        if(!xmlConverted&&!xmlParsed)
            errormsg = "Error while CONVERSION & PARSING of config id "+cfg.getCfgId().toString()+", took "+getElapsedTime(startTime)+ " time."
        else if(!xmlConverted)
            errormsg = "Error while CONVERSION of config id "+cfg.getCfgId().toString()+", took "+getElapsedTime(startTime)+ " time."
        else if(!xmlParsed)
            errormsg = "Error while PARSING  of config id "+cfg.getCfgId().toString()+", took "+getElapsedTime(startTime)+ " time."
        logger.info errormsg
    }

    makeDatabaseEntriesForConvertStatus(csmConfigConvertStatus,oldCSMSession)
}

This currently works for 20 records, but I am not sure how will it react for all 10000 records. Please help

Update

I takes about 3-6 secs for each config

  • 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-06-14T11:19:06+00:00Added an answer on June 14, 2026 at 11:19 am

    It will always be more efficient to use a pool of database connections, let a container manage establishing and closing that connection when required. Creating a connection, executing your statement and then closing that connection can be avoided with a pool which will pre-connect before giving you the connection to use and in most cases (particulars for what you described) the connection will not need to be made given it will likely be connected already.

    So therefore yes it is more efficient to keep the connection open and even better to pool your connections…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have two databases...old structure and new structure... i wrote a converter that copies
i have two databases...old structure and new structure... i wrote a converter that copies
I have two databases($db1, $db2) with exact table structure(table1). $db2.table1 has new rows which
We are upgrading/converting several old Access databases to MS-SQL. Many of these databases have
I Have a old database to maintain .... they have stored html tags in
I have an old database and a new database. The old records were converted
I have a database full of autopart numbers that needs old part numbers prices
I have two websites OLD.com (classic ASP) and NEW.com (ASP.NET) - each site has
I have some legacy DB with many tables (around 100) the old system is
I have several (old) Drupal-sites that need to be replaced with one single new

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.