473,499 Members | 1,691 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

org.postgresql.util.PSQLException: FATAL: sorry, too many clients already

1 New Member
Hi,
Following is my code that does some initial accounts creation in bulk for some purpose.

After creating about 52 accounts it gives the following error:

org.postgresql.util.PSQLException: FATAL: sorry, too many clients already

Unless I am overlooking something , I open only one database connections, making 3 SQL Statatements, 3 ResultSets.

I am running Postgresql Server 9.3
My Postgresql.conf file semms OK with max_connections=100

I would greatly appreciate if somebody can help me resolve my problem

// ****************************************
Expand|Select|Wrap|Line Numbers
  1. public void CreateAccounts()
  2.     {
  3.         PreparedStatement ps1 = null;
  4.         PreparedStatement ps2 = null;
  5.         String sql1 = "SELECT * FROM \"CHART_OF_ACCOUNTS\" "; // WHERE \"ACCOUNT_ACTIVE\" = 'Y' ";
  6.         String sql2 = "SELECT * FROM \"MEMBER_ACCOUNTS\"  ";
  7.         String sql3 = "SELECT * FROM \"ECCS_MEMBERSHIP\" WHERE \"COMPANY_CODE\" = ?  AND \"EMPLOYEE_TYPE\" = ?  AND \"ECCS_MEMBER_NO\" "
  8.                 + " > '5265'  ORDER BY \"ECCS_MEMBER_NO\"  ";
  9.         Statement stmt1 = null;
  10.         Statement stmt2 = null;
  11.         PreparedStatement ps  = null;
  12.         ResultSet rs1 = null;
  13.         ResultSet rs2 = null;
  14.         ResultSet rs3 = null;
  15.         Connection con = null;
  16.         String eccsNo = null;
  17.         String thriftAccountNo = null;
  18.         String sharesAccountNo = null;
  19.         String loanAccountNo = null;
  20.         String dividendAccountNo = null;
  21.         String employeeType = textEmployeeType.getText();
  22.         String companyCode = textCompanyCode.getText();
  23.  
  24.         try {
  25.             con  = postgresoperations.ConnectionPool.getConnection();
  26.             stmt1 = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
  27.             stmt2 = con.createStatement( ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
  28.             ps = con.prepareStatement(sql3);
  29.             rs1 = stmt1.executeQuery(sql1);
  30.             rs2 = stmt2.executeQuery(sql2);
  31.             ps.setString(1, companyCode );
  32.             ps.setString(2, employeeType );
  33.             rs3 = ps.executeQuery();
  34.             int  i=0;
  35.             while(rs3.next())
  36.             {
  37.                 try {
  38.               //      con.setAutoCommit(false);
  39.                     System.out.println("in OneTimeMembersAccountsCreation");
  40.              //       String accountNo = rs1.getString("ACCOUNT_NO"); 
  41.  
  42.          //           rs1.moveToCurrentRow(); COMMENTED ON 20-09-2014
  43.          //           rs2.moveToInsertRow();  COMMENTED ON 20-09-2014
  44.  
  45.                     eccsNo = rs3.getString("ECCS_MEMBER_NO");
  46.        //             employeeType = rs3.getString("EMPLOYEE_TYPE"); 
  47.        //             companyCode = rs3.getString("COMPANY_CODE");
  48.                     thriftAccountNo  = MakeupAccountNo(eccsNo, textThriftAccountNo.getText());
  49.                     loanAccountNo  = MakeupAccountNo(eccsNo, textLoanAccountNo.getText());
  50.                     sharesAccountNo  = MakeupAccountNo(eccsNo, textSharesAccountNo.getText());
  51.         //            dividendAccountNo  = MakeupAccountNo(eccsNo, textDividendAccountNo.getText());
  52.  
  53.                     SetChartOfAccounts(rs1,eccsNo, thriftAccountNo, "L", textThriftAccountNo.getText());// , sharesAccountNo, loanAccountNo);
  54.                     SetChartOfAccounts(rs1,eccsNo, loanAccountNo, "A", textLoanAccountNo.getText());
  55.                     SetChartOfAccounts(rs1,eccsNo, sharesAccountNo, "C", textSharesAccountNo.getText());
  56.            //         SetChartOfAccounts(rs1,eccsNo, dividendAccountNo, "L", textDividendAccountNo.getText());
  57.                     SetMemberAccounts(rs2,eccsNo, thriftAccountNo,  sharesAccountNo, loanAccountNo, dividendAccountNo);
  58.                     System.out.println("in CreateAccounts, membeTthriftAcountNo = " + "-" + thriftAccountNo +"-");
  59.            //         rs2.updateInt("FISCAL_YEAR", fiscalYear);
  60.            //         rs2.updateString("ACCOUNT_NO", accountNo);
  61.            //         rs2.updateDouble("BALANCE", 0.00);
  62.            //         rs2.insertRow();
  63.                     i++;
  64.                     if(i==2500)
  65.                         break;
  66.                 } catch(SQLException e) {
  67.                 //    try {
  68.                 //        con.rollback();
  69.                 //    } catch(SQLException ex) {
  70.                 //        System.out.println(ex.getMessage());
  71.                 //    }
  72.                   System.out.println(e.getMessage());
  73.                 }
  74.             }
  75.             con.close(); // close connection
  76.         } catch(SQLException e) {
  77.             System.out.println(e.getMessage());
  78.             e.printStackTrace();
  79.  
  80.         }
  81.  
  82.         System.out.println("DONE======================");
  83.     }
Dec 23 '14 #1
0 5930

Sign in to post your reply or Sign up for a free account.

Similar topics

1
10392
by: Egil M?ller | last post by:
I'm developing a larger Python program, and one component (a text parser for a networking protocol) happend to be terribly slow, while quite a simple piece of code, so I decided to reimplement it...
1
26185
by: Dan | last post by:
I have a server under very light load -- just me doing some work in php. I am getting this error often and don't know why: postgresql max connections Unable to connect to PostgreSQL server:...
1
3236
by: James Moe | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hello, Postgesql v7.3.2, os/2. I am using JDBC to connect to the dbms. After a few program open/close I get the message "Sorry, too many clients...
0
2323
by: Philippe Lang | last post by:
Hello, After using Postgresql for a while, through ODBC / MS Access, I'm not able to connect to the server anymore. The server reports "Too many clients connected already". With a "ps -afx",...
2
2827
by: osmarjunior | last post by:
Hi, I'm using ODBC to connect to the dbms (Postgresql v8.1, in Windows server). After a few program open/close I get the message "Sorry, too many clients already". I believe my database class...
1
4280
by: ntech | last post by:
When connecting to postgresql datbase server, it says to many clients already. So what is the solution of this problem? and how can we view the client connections. Thanks, Ntech
1
1864
by: vaishalich | last post by:
Hi I m using SQL server database and i wanted to know how many clients are currently connected to SQL server.
6
3681
by: bill | last post by:
I have been "Googling" for about an hour and am turning up squat! I just started receiving this error when trying to log into a MS Access database from a vb .net web application. Recycling IIS...
2
3257
by: adisabat | last post by:
Hi I was linking a lot of libraries on Solaris10 sun studio 12 and I got the following errors: ld: fatal: too many symbols require `small' PIC references: have 3942, maximum 2048 --...
1
1362
by: priyamurugar | last post by:
hi..... I wrote one server program handling many clients in java........... If the server fails, how to handle the clients.... I want to write two server programs...
0
7134
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7014
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7180
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7229
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6905
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
4921
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3108
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3103
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
667
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.