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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T20:35:10+00:00 2026-06-05T20:35:10+00:00

ComboPooledDataSource cpds = new ComboPooledDataSource(); cpds.setDriverClass( com.mysql.jdbc.Driver ); //loads the jdbc driver cpds.setJdbcUrl( jdbc:mysql://localhost:3306/dragon

  • 0
ComboPooledDataSource cpds = new ComboPooledDataSource(); 
cpds.setDriverClass( "com.mysql.jdbc.Driver" ); //loads the jdbc driver 

cpds.setJdbcUrl( "jdbc:mysql://localhost:3306/dragon" ); 
cpds.setUser("root"); 
cpds.setPassword("password");
cpds.setMaxPoolSize(50);

I’ve created a java file containing the following code to configure a ComboPooledDataSource object. Now is this code enough to establish a pooled connection with the database?

If not, What else should I do ?

Also please tell how can I can implement JNDI here.

Please explain it since I am a beginner.

  • 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-05T20:35:12+00:00Added an answer on June 5, 2026 at 8:35 pm

    At First…Create the code to initiate the connection in a class containing static methods or variables like this the following..

            private static ComboPooledDataSource cpds = new ComboPooledDataSource();
            public static void MakePool()
            {
                   try 
                   {
                     cpds=new ComboPooledDataSource();
                     cpds.setDriverClass("com.mysql.jdbc.Driver");
                     cpds.setJdbcUrl("jdbc:mysql://localhost:3306/att_db");
                     cpds.setUser("root");
                     cpds.setPassword("dragon");
                     cpds.setMaxPoolSize(MaxPoolSize);
                     cpds.setMinPoolSize(MinPoolSize);
                     cpds.setAcquireIncrement(Accomodation);
                 } 
                 catch (PropertyVetoException ex) 
                 {
                     //handle exception...not important.....
                  }
    
    }
    public static Connection getConnection()
    {
               return cpds.getConnection();
    }
    

    Once u r done Create another class meant for server operations….

    and get the Connections from the Pool…

             try{
    
                   con=DatabasePool.getConnection();
                   // DatabasePool is the name of the Class made earlier....
                   .
                   .
                   .
                   .  // Server operations as u wanted.....
                   .
                   .
                 }
                 catch(SQL EXCEPTION HERE)
                 {
                      .....
                 }
                 finally
                 {     
                   if(con!=null)
                   {
                          con.close();      
                   }
                 }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to Spring . I am using ComboPooledDataSource for connection pooling in
First of all, I'm new to Java. I'm trying to figure out what would
It's my first time I'm using ComboPooledDataSource in hibernate, but there's something wrong with
I recently switched to Spring Framework instead of manually handling JDBC, and it is
For some strange reason I can't seem to add UTF-8 data to my MySQL
I am processing a large amount of data in a Spring JDBC DAO. The
I have a threaded chat server application which requires MySQL authencation. Is the best
How to get the inner connection object from the ComboPooledDataSource.
I have a datasource set in my Jetty.xml file that looks like this: <New
I have created a basic Spring 3.1 - Hibernate 4 - Mysql 5.5 web

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.