简体   繁体   English

使用postgresql的非常简单的jsf应用程序中“已经有太多客户端”

[英]“too many clients already” in a very simple jsf app using postgresql

I'm getting the "FATAL: sorry, too many clients already" after only a few clicks around on my web application. 在我的Web应用程序上单击几下后,我得到了“致命:抱歉,已经有太多客户”。 The app is written using JSF 2. I haven't the slightest idea why this this is happening. 该应用程序是使用JSF 2编写的。我丝毫不知道为什么会发生这种情况。 I know for a fact I am the only person connected. 我知道,事实上,我是唯一联系的人。 It happens regardless of whether or not I am also connected using pgadminIII. 无论是否也使用pgadminIII进行连接,都会发生这种情况。 My app is ridiculously simple. 我的应用程序非常简单。

Here are some relevant bits which may help: 以下是一些可能有用的相关信息:

Here's a singleton class I use for the connection: 这是我用于连接的单例类:

public class ConnectionSingleton{

private static Connection con;

public static Connection getConnection() throws SQLException
{
    if (con == null || con.isClosed())
    {

        try
        {
            Class.forName("org.postgresql.Driver");

            con = DriverManager.getConnection(
                    "jdbc:postgresql://127.0.0.1:5432/sc_data", "postgres",
                    "password");
        } catch (SQLException e)
        {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (ClassNotFoundException e)
        {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    return con;
}
}

Here's an example of typical usage: 这是典型用法的示例:

    try
    {
        Connection con = ConnectionSingleton.getConnection();

        PreparedStatement stat = con.prepareStatement("select * from song_song where id = ?");
        stat.setInt(1, id);
        ResultSet res = stat.executeQuery();

        if (res.next())
        {               
            id = res.getInt("id");
            name = res.getString("s_name");
            link = res.getString("s_link");
            owner = res.getInt("s_owner");
            critNumber = res.getInt("s_crit_number");

            retval="found";

        }
        else
        {
            retval = "no song";
        }

        res.close();
        con.close();
        stat.close();


    } catch (SQLException e)
    {
        retval = "no song";
        e.printStackTrace();
    }

I can't think of anything else to include here. 我想不出要在这里包含的其他内容。 that's pretty much it. 就是这样。 Any ideas? 有任何想法吗?

通常,当您看到此消息时,您的应用程序/ Web服务器配置的子级要多于postgresql配置的允许后端连接的子级。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM