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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T05:42:25+00:00 2026-05-30T05:42:25+00:00

Currently, I load the below custom driver (TestDriver.java), get a connection, create a Statement,

  • 0

Currently, I load the below custom driver (TestDriver.java), get a connection, create a Statement, execute a query, gets the results and close the connection. I open and close a connection for each query. Is this common practice or is there an standard way to share the open connections?

    public static void main(String[] args) {
        Class.forName("com.sql.TestDriver");
        java.sql.Connection conn = DriverManager.getConnection("jdbc:test://8888/connectme", props);
        Statement stmt = conn.createStatement;
        ResultSet rs = stmt.executeQuery("select * from table");
        //loop through rs and pull out needed data
        conn.close();  
    }


    public class TestDriver implements java.sql.Driver{
        private final TestSchema schema;
        private Properties props = null;
        static {
            try {
                DriverManager.registerDriver(new TestDriver());
            } catch (SQLException e) {
                e.printStackTrace();
            }

        protected TestDriver() throws SQLException {
            schema = TestSchemaFactory.getInstance().getDbSchemaFromFile(SCHEMA_FILE);
            //loads in and parses a file containing tables, columns used for business logic
        }
        public Connection connect(String url, Properties info) 
                throws SQLException {
           TestSqlConnection conn=null;
           //connect logic here
           return conn; //will return an instance of TestSqlConnection
        }

    @Override
    public boolean jdbcCompliant() {
        return false;
    }
}
  • 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-30T05:42:26+00:00Added an answer on May 30, 2026 at 5:42 am

    Yes, it’s more common to use a database connection pool. This will allow connections to be reused without the overhead or closing/re-opening. Here’s a link to DBCP which is one implementation of a database connection pool: http://commons.apache.org/dbcp/

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

Sidebar

Related Questions

I am currently using the below code to get a list of uuid's then
I am currently using the code below to load images but I want to
I have couple resource DLLs that I currently load when application starts using following
We currently have code like this: Dim xDoc = XDocument.Load(myXMLFilePath) The only way we
I'm currently getting a Could not load type UI.Administration.Site.master error message and I'm not
Currently I use .Net WebBrowser.Document.Images() to do this. It requires the Webrowser to load
I currently have issues in Webkit(Safari and Chrome) were I try to load dynamically
I am currently using a RadTreeView and just switched over to using Load-On-Demand (ServerSideCallback)
For my iPhone 3D apps I am currently using CoreGraphics to load png files
I have a web application that can load plugins through reflection. It currently uses

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.