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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T17:02:28+00:00 2026-06-05T17:02:28+00:00

I have a static class that I use as my Data Utils for my

  • 0

I have a static class that I use as my “Data Utils” for my project.

This project has several forms and classes, multiple of which make calls to this Data Utils class/the database.

I don’t want to violate the DRY principle, so I don’t want to have multiple OracleConnection components, one plopped onto each form.

I also don’t want to violate cohesion by having my Data Utils class gain “carnal” knowledge of my main form and access it for the OracleConnection.

I could create a dynamic OracleConnection inside each Data Utils method, but that, too, would violate DRY.

Is my best solution to convert my static class to non-static, give it an OracleConnection member, and instantiate that in the constructor?

UPDATE

For future generations, this is what I did, based on LukLed’s suggestion:

internal class GreatAmericanNovelistsData
{
    private static OracleConnection oc;
    static GreatAmericanNovelistsData()
    {
        oc = new OracleConnection();
        oc.ConnectionString = "User Id=SCLEMENS;Password=HucKfiNn;Server=HANNIBAL;Pooling=True;Min Pool Size=0;Max Pool Size=10;Connection Lifetime=0;Direct=True;Sid=HANNIBAL;Service Name=HANNIBAL;";
        oc.Direct = true;
    }
  • 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-05T17:02:29+00:00Added an answer on June 5, 2026 at 5:02 pm

    You can define static constructor and initialize connection only once. OracleConnection object can be static too. Details here.

    class SimpleClass
    {
        // Static constructor
        static SimpleClass()
        {
            //...
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In project A, i have a static class which stores data for specific types,
I have a static class that looks like this: namespace Argus { static class
I have a static methods class, Utils, that is basically for utility methods, its
I have a static class in my ASP.NET app that I use to hold
I have an ASP.NET application where I use static class as cache. Inside that
So I have a static class that is supposed to be used as a
I have a static util class that does some string manipulation on a bit
Suppose I have a static method of my class that returns an object of
I have class A such that: class A { static int i; A(); f1();
I currently have a helper class that I am using to obfuscate a static

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.