Link to home
Start Free TrialLog in
Avatar of Arawn
Arawn

asked on

PostGresql - non superuser connection limit exceeded

I am running a JSP application on Tomcat that refreshes every minute. When it refreshes, it opens a connection to the DB, executes a few queries/updates, and then closes all the connections. I have similar pages in my app that do similar things.

One page though consistently blows up after about 20 minutes. It gives me a Fatal exception that says the "non superuser connection limit is exceeded". I have tried to figure out what is going wrong, especially since I know that I am closing the connections each time, and I know it is specific to PostGresql because the same pages run fine with an MS SQL db in the backend.

Does anybody have any ideas? I have checked the Postgresql site and there was nothing really helpful there that I could find.
ASKER CERTIFIED SOLUTION
Avatar of stoneman
stoneman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Arawn
Arawn

ASKER

stoneman

I don't think I am using the superuser account, because this is actually a hosted database. And I can't see any hosting company giving away the superuser password.

The pertinent info from the page is below. I have truncated a whole bunch of things that aren't important. The main thing is that it is clear that the page is refreshing, and that the connection is being closed.

<%
response.setHeader("Cache-Control","no-store");
response.setHeader("Pragma","no-cache");
response.setIntHeader("Refresh", 60 );

String sql="select aucID from auctionAuctions where aucEnded=0 and aucCloseDate<'"+currSQLDate+"' and aucNumBid>0";
java.util.ArrayList openAuctions=new java.util.ArrayList();
Class.forName(jdbc_driver);  
Connection con =       DriverManager.getConnection(jdbc_databaseURL,jdbc_username,jdbc_password);  
Statement stmt = con.createStatement();
ResultSet rs=stmt.executeQuery(sql);
while(rs.next()){      
      openAuctions.add(""+rs.getInt("aucID"));
}
for(int x=0; x<openAuctions.size(); x++){
      sql="select auctionItems.itemTitle, auctionAuctions.aucCurrentBid, auctionUsers.userEmail from auctionItems, auctionAuctions, auctionUsers  where aucID="+openAuctions.get(x)+" and auctionUsers.UserID=auctionAuctions.aucCurrentBidder and auctionAuctions.aucItemID=auctionItems.itemID";
      rs= stmt.executeQuery(sql);
      if(rs.next()){      
                      // do stuff
      rs.close();      
      }      
}
sql="update auctionAuctions set aucEnded=1 where aucCloseDate<'"+currSQLDate+"' and aucNumBid=0";
stmt.executeUpdate(sql);
stmt.close();
con.close();
%>
Avatar of Arawn

ASKER

It ended up being a problem on the host's side. Thanks for answering.