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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:56:16+00:00 2026-06-14T04:56:16+00:00

I’m having problems when I create a database pool with PGPoolingDataSource class, after a

  • 0

I’m having problems when I create a database pool with PGPoolingDataSource class, after a while the pool goes down when many users are working and shows no errors

The code of the class that creates the pool is:

public class PgConexion {
    private static PgConexion _instancia = new PgConexion(); // instancia de la clase
    private Configuracion config;
    private PGPoolingDataSource source;

    /**
     * instancia la clase y carga las opciones de configuracion
     */
    public PgConexion() {
        final URL archivo = Constantes.RUTA_CONFIG;

        if(archivo != null){
            config = new Configuracion(archivo);
        }
    }

    /**
     * regresa la instancia del pool de conexiones
     * @return
     */
    public static PgConexion getInstance() {
        return _instancia;
    }

    /**
     * crear la conexion la conexion
     * @return
     * @throws SQLException
     */
    public void crearConexion() throws SQLException{
        source = new PGPoolingDataSource(); 

        // configuracion del pool
        source.setDataSourceName("Logistica");
        source.setServerName(config.get("servidor_sql"));
        source.setPortNumber(Integer.parseInt(config.get("puerto_sql")));
        source.setDatabaseName(config.get("bd_sql"));
        source.setUser(config.get("usuario_sql"));
        source.setPassword(config.get("contrasena_sql"));
        source.setMaxConnections(30);
    }

    /**
     * devuelve la conecion a utilizar
     * @return
     * @throws SQLException
     */
    public Connection nuevaConexion() throws SQLException{
        if(source == null){
            crearConexion();
        }

        // genero la conexion de la lista del pool
        return source.getConnection();
    }

    /**
     * Cierra las conexiones y libera los recursos
     */
    public void cerrarConexion(){
        source.close();
    }
}

How do I fix this?

  • 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-14T04:56:17+00:00Added an answer on June 14, 2026 at 4:56 am

    It is not a very good idea to use PGPoolingDataSource, as JDBC documentation explains.

    The base problem is that the call for getConnection() will be blocked until a connection is closed when the limit of connections has been reached.

    You’ve set the value 30 as the max amount of concurrent conections, so if a 31st is intended to be opened, it will cause a block on the Thread making the call.

    Possible solutions:

    • Increase maxConnections, if you are certain about the real amount of concurrent connections upper limit. You should also check the server-side connection limit in postgresql.conf.
    • Use PGSimpleDataSource. Depending on the type of application, not using a pool of connections (thus creating the connection each time) will not be a problem.
    • If you really need a pool of connections, simply implement your own at Java level.

    EDIT: You can check the amount of opened connections by simply running:

    SELECT * FROM pg_stat_activity
    

    Each row is a connection (including the one from pgAdmin and the query analyser). If you are certain that the number of connections should not raise up to the upper limit (but nevertheless it does), maybe you are having some sort of connection leak problem.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
Let's say I'm outputting a post title and in our database, it's Hello Y’all
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I've tracked down a weird MySQL problem to the two different ways I was
I'm trying to create an if statement in PHP that prevents a single post

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.