Too many connections!what can i do?help :)

Hello,everyone!
I am a programmer in China,I like java,During working I met a question,please give me some indicate!
//the main program
public void actionPerformed(ActionEvent e){
mysqldatabean mysqldata=new mysqldatabean();
String sql1="select*from talbe1";
ResultSet rs1=mysqldata.mysqlexecuteQuery(sql1);
try{
while(rs1.next()){
String id=rs1.getString("id");
String sql2="select*from table2 where id='"+id+"'";
ResultSet rs2=mysqldata.mysqlexecuteQuery(sql2);
try{
while(){
catch(SQLException ex){}
mysqldata.destroyconnection();
catch(Exception ex){}
mysqldata.destroyconnection();
//the class
class mysqldatabean {
String mysqlDBDriver = "sun.jdbc.odbc.JdbcOdbcDriver";
String mysqlConnStr = "jdbc:odbc:mysqldata";
Connection mysqlconn = null;
ResultSet mysqlrs = null;
Statement mysqlstmt=null;
public mysqldatabean() {
try {
Class.forName(mysqlDBDriver);
catch(java.lang.ClassNotFoundException e) {
System.err.println("mysqlexecuteQuery: " + e.getMessage());
public ResultSet mysqlexecuteQuery(String mysqlsql) {
try {
mysqlconn = DriverManager.getConnection(mysqlConnStr);
mysqlstmt = mysqlconn.createStatement();
mysqlrs = mysqlstmt.executeQuery(mysqlsql);
catch(SQLException ex) {
System.err.println("mysqlexecuteQuery: " + ex.getMessage());
return mysqlrs;
public void destroyconnection(){
boolean connboolean=false;
try{
mysqlconn.close();
connboolean=mysqlconn.isClosed();
catch(SQLException ex){}
Question:
because of large number of datas,while execute,Exception:mysql server, odbcdriver too many connections, getSQLState:s1000
how can i change this program?please give me the anwser(code),I need it immediately!
Help!!:)
[email protected]

// You are trying to establish connection for all statements.
// You only need connection per database connection not per statement.
// Try to create connection outside of mysqlexecuteQuery()
mysqldatabean mysqldata=new mysqldatabean();
String sql1="select*from talbe1";
mysqlconn = DriverManager.getConnection(mysqlConnStr);
ResultSet rs1=mysqldata.mysqlexecuteQuery(sql1);
public ResultSet mysqlexecuteQuery(String mysqlsql) {
try {
mysqlstmt = mysqlconn.createStatement();
mysqlrs = mysqlstmt.executeQuery(mysqlsql);
catch(SQLException ex) {
System.err.println("mysqlexecuteQuery: " + ex.getMessage());
return mysqlrs;

Similar Messages

  • My iPad says that I have authorize too many times what can I do to fix this problem?

    MY iPad says that I have authorized it too many times, how do I fix this problem?

    OverDrive has its own application for its media. See <http://omc.overdrive.com/v3-available-now/ios.php>. This has nothing to do with the Adobe Reader for iOS. Sorry!
              - Dov

  • Got my i phone disabled because i tried my pass code too many times  what can i do now

    I locked my i phone by entering my unlock code too mamy tiimen and now its disabled. cant get into it     LOCKED ME OUT!  need help

    See http://support.apple.com/kb/ht1212

  • Too many connections - even after closing ResultSets and PreparedStatements

    I'm getting a "Too many connections" error with MySQL when I run my Java program.
    2007-08-06 15:07:26,650 main/CLIRuntime [FATAL]: Too many connections
    com.mysql.jdbc.exceptions.MySQLNonTransientConnectionException: Too many connections
            at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:921)
            at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2870)
            at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:812)
            at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:3269)
            at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1182)
            at com.mysql.jdbc.Connection.createNewIO(Connection.java:2670)I researched on this and found out that I wasn't closing the ResultSet and the PreparedStatement.
    The JDBC connection is closed by a central program that handles connections (custom connection pooling).
    I added the code to close all ResultSets and PreparedStatements, and re-started MySQL as per the instructions here
    but still get "Too many connections" error.
    A few other things come to mind, as to what I may be doing wrong, so I have a few questions:
    1) A few PreparedStatements are created in one method, and they are used in a 2nd method and closed in the 2nd method
    does this cause "Too many connections" error?
    2) I have 2 different ResultSets, in nested while loops where the outer loop iterates over the first ResultSet and
    the inner loop iterates over the second ResultSet.
    I have a try-finally block that wraps the inner while loop, and I'm closing the second ResultSet and PreparedStement
    in the inner while loop.
    I also have a try-finally block that wraps the outer while loop, and I'm closing the first ResulSet and PreparedStatement
    in the outer while loop as soon as the inner while loop completes.
    So, in the above case the outer while loop's ResultSet and PreparedStatements remain open until the inner while loop completes.
    Does the above cause "Too many connections" error?
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    The following is relevant sections of my code ( it is partially pseudo-code ) that shows the above 2 cases:
    init( Connection jdbcConnection ){
       String firstSQLStatement = "....";
       PreparedStatement ps1 = jdbcConnection.prepareStatement( firstSQLStatement );
       String secondSQLStatement = "....";
       PreparedStatement ps2 = jdbcConnection.prepareStatement( secondSQLStatement );
       String thirdSQLStatement = "....";
       PreparedStatement ps3 = null;
       ResultSet rsA = null;
       try{
            ps3 = jdbcConnection.prepareStatement( thirdSQLStatement );
            rsA = ps3.executeQuery();
            if( rsA.next() ){
                   rsA.getString( 1 );
       }finally{
            if( rsA != null )
                   rsA.close();
            if( ps3 != null )
              ps3.close();
       //Notice, how ps1 and ps2 are created here but not used immediately, but only ps3 is
       //used immediately.
       //ps1 and ps2 are used in another method.
    run( Connection jdbcConnection ){
         ResultSet rs1 = ps1.executeQuery();
            try{
               while(rs1.next()){
                    String s = rs1.getString();
                    ps2.setString(1, s);
              ResultSet rs2 = ps2.executeQuery();
                    try{
                   while(rs2.next()){
                        String s2 = rs2.getString();
                    }finally{
                   if( rs2 != null )
                     rs2.close();
                   if( ps2 != null )
                     ps2.close();
         }catch( Exception e ){
              e.printStackTrace();
         }finally{
            if( rs1 != null )
                  rs1.close();
               if( ps1 != null )
                  ps1.close();
    //Notice in the above case rs1 and ps1 are closed only after the inner
    //while loop completes.
    }I appreciate any help.

    Thanks for your reply.
    I will look at the central connection pooling mechanism ( which was written by someone else) , but that is being used by many other Java programs others have written.
    They are not getting this error.
    An addendum to my previous note, I followed the instructions here.
    http://dev.mysql.com/doc/refman/5.0/en/too-many-connections.html
    There's probably something else in my code that is not closing the connection.
    But I just wanted to rule out the fact that opening a PreparedStatement in one method and closing it in another is not a problem.
    Or, if nested ResultSet loops don't cause the problem.
    I've read in a few threads taht "Too many connections" can occur for unclosed RS and PS , and not just JDBC connections.

  • Too many connections to call SAP functions

    Hello everyone,
    I'm having a random problem while accessing SAP functions on my applications.
    Sometimes i get this message:
    Could not create JCOClientConnection for logical Systems: WD_MODELDATA_DEST - Model: class com.xxx.sap.NameController.
    Please assure that you have configured the RFC connections and/or logical system name properly for this model.
    A friend tells me that this has to do with the fact that i use one model per SAP function ,
    and a custom controller for each unique model.
    This creates too many connections and launches the error.
    Can anyone tell me how to solve this problem without
    having to reimport all my functions into one single model  and one single custom controller ??
    My biggest problem is that doing that would increase the time spent on project development dramatically.
             Thank you everyone,
                  Nuno Santos

    Hi Guillaume,
    My answers:
    1. All connections are closed by time-out, but i would really apreciate if someone could explain how to explicitly close them after calling them.
    2. No. That is the big problem. This was my first project, and in a very simplistic (and stupid) way i created a webdynpro model for each SAP function that i call. This means that an application may call 5 or 6 functions during it's runtime, meaning 5 or 6 connections. Multiply this by a few hundred users...
    What are my choices here?
    Help will be really apreciated.
       Thanks to everyone,
           Nuno Santos

  • ICloud mail "Too many connections" error

    Anyone ever gotten this error when sending to an @me.com account? This is what it looks like when I send email to myself using it. My gut says it's a Boxcar issue but I haven't used that service in months and I've now disconnected anything from it. This is the error I'm seeing back when sending email to my iCloud account:
    This report relates to a message you sent with the following header fields:
    Message-id: <[email protected]>
    Date: Wed, 07 Nov 2012 14:29:50 -0500
    From: Brad Franklin <[email protected]>
    To: Brad Franklin <[email protected]>
    Subject: Test
    Your message cannot be delivered to the following recipients:
    Recipient address: [email protected]
    Original address: [email protected]
    Reason: Rejection greeting returned by server.
    Diagnostic code: smtp;554 Transaction failed. Too many connections.
    Remote system: dns;push.boxcar.io (TCP|17.172.204.240|45227|173.192.56.11|25) (Transaction failed. Too many connections.)
    Original-envelope-id: [email protected]
    Reporting-MTA: dns;st11p01mm-asmtp005.mac.com (tcp-daemon)
    Arrival-date: Wed, 07 Nov 2012 19:29:54 +0000 (GMT)
    Original-recipient: rfc822;[email protected]
    Final-recipient: rfc822;[email protected]
    Action: failed
    Status: 5.0.0 (Rejection greeting returned by server.)
    Remote-MTA: dns;push.boxcar.io (TCP|17.172.204.240|45227|173.192.56.11|25)
    (Transaction failed. Too many connections.)
    Diagnostic-code: smtp;554 Transaction failed. Too many connections.

    I'm also having this issue with two of my accounts (the main ones I use the most!) I get this message:

  • Mail Alert with Triangle Exclamation Mark with iMap - Too Many Connections?

    I have one Laptop (Macbook mid-07) on Leopard 10.5.6 and a Macbook Pro 09 on Leopard 10.5.8. I just switched over to iMap where I have two email accounts set up on both laptops. Both laptops have identical accounts set up on them.
    I'm currently geting the triangle with the exclamation mark alert on the inboxes of both accounts when both laptops have Apple Mail open. Is this an issue with Apple Mail or my Service Provider possibly complaining that I have too many connections? I don't get these alerts when only one laptop has the Mail App open. The alert reads:
    Alert
    There may be a problem with the mail server or the network. Check the settings for the account "IMAP" or try again.
    The server error encountered was: The attempt to read data from the server "mail.mydomain.com" failed.
    However, Mail seems to send and receive okay with the alerts popping up and so I'm not sure if this alert is anything to be serioulsy concerned about. Or, is there a way to fix this?

    I set mail to fetch messages every 15 minutes where I delayed one laptop in opening up mail initially by 5 minutes. That way, both laptops are not fetching mail concurrently and there's a gap of time for them to download mail before the other starts. This seemed to have fix this alert issue and I'm no longer getting these messages.
    Although, 15 minutes seems to be a bit long for auto fetching since my email can be under some time constraints. Does anyone know how to set the time to check every 10 minutes which I can probably live with? Currently, I have the option to set for 1 minute, 5 minutes, 15 minutes, 30 minutes, 1 hour, or manually.

  • My iPad mini keeps turning itself off and then the apple logo keeps flashing constantly, i have charged it fully and restored it many times. what can i do?

    My iPad mini keeps turning itself off and then the apple logo keeps flashing constantly, i have charged it fully and restored it many times. what can i do?

    If you have restored to factory settings and started as new, there is nothing more that you can do on your own. Make an appointment at an Apple Store and ask them for help. You might have a hardware problem and the Apple Store techs will be able to determine that.

  • Error "421 #4.4.5 Too many connections from your host"

    We have deployed a Java application using JavaMail which enables people to send email to their contact lists. It has been in use for a few years, various updates being applied over that time. Most of our customers have no problem. But a couple of weeks ago, two of them suddenly could no longer send emails.
    The connection to the SMTP server works but when the application sends email, it gets an error 421. A debugging dump is reproduced below: the target email address is changed to protect the uninvolved; messages starting with **** come from my program, other come from JavaMail.
    Can anyone solve this problem? suggest where to look? Thanks.
    DEBUG SMTP: useEhlo true, useAuth true
    DEBUG SMTP: trying to connect to host "smtp10.bellnet.ca", port 25, isSSL false
    220 toip35-bus.srvr.bell.ca ESMTP
    DEBUG SMTP: connected to host "smtp10.bellnet.ca", port: 25
    EHLO Communications
    250-toip35-bus.srvr.bell.ca
    250-8BITMIME
    250 SIZE 20971520
    DEBUG SMTP: Found extension "8BITMIME", arg ""
    DEBUG SMTP: Found extension "SIZE", arg "20971520"
    **** transport connect worked
    NOOP
    250 ok
    **** about to send message to [email protected]
    NOOP
    250 ok
    DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]
    DEBUG SMTP: useEhlo true, useAuth true
    **** cEmailAuthenticator.getPasswordAuthentication() called
    DEBUG SMTP: useEhlo true, useAuth true
    DEBUG SMTP: trying to connect to host "smtp10.bellnet.ca", port 25, isSSL false
    421 #4.4.5 Too many connections from your host.
    DEBUG SMTP: could not connect to host "smtp10.bellnet.ca", port: 25, response: 4

    Looks like the server keeps track of the number of connections from each machine, and when the number of connections in a certain period exceeds some number, that machine is deemed to be a potential spammer. At any rate it is something you should discuss with the manager of that server.

  • Why Customer get too many "Connection reset by peer"

    Hi,
    I have CSS 11503 V7.50 without SSL Module.
    I have 4 real servers and LB method is Round Robin. Customer tests the methods by using two way.
    First A requestor try to connect service via VIP address.Second requestor try to connect to real servers by using directly real server IP address (Bypass Load balacer)
    Customer cheks the real server logs and sees that in first experiment (via VIP) there too many "connection reset by peer" messages. For second experiment there are few same messages.
    I wonder why real servers get this messages. Plus, why CSS reset flows. I know flow timeout does that. But if there are too many idle flows, it says something wrong?

    There is a command, but I was more thinking about the server side counter or log info.
    If you really want to see if the CSS sent a RESET or not, you can use the following engineering command
    CSS11503-2(debug)# symbol-table load SPRITZ
    Loading string table... 660,706
    Loading symbols........ 24,937
    Load complete.......... 1,259,194
    CSS11503-2(debug)# shell 1 1 FMShowReset
    FM RESET COUNTERS:
    Last FM Reset Case was 7
    0 Case 1: Server Flow not in WCC
    0 Case 2: Client Flow not in WCC
    0 Case 3: FM_ContentHandleUnexpectedTermination
    0 Case 4: Server not responding on backend, reset client
    0 Case 5: Server not responding on backend, reset server
    0 Case 6: WCC returns empty vector, reset client
    18 Case 7: Reset to server on DOS attack
    2 Case 8: FM_HandleEarlySpoofTermination
    0 Case 9: Reset client if join fails in spoof flow
    0 Case 10: TCP SYN Exceeded
    0 Case 11: Reset server on remap backend connection
    0 Case 12: WCC did not return WCC_TCP_SPOOF for FAUX SYN
    0 Case 13: FM_HandleFinalClose
    0 Case 14: FM_CreateRedirectServerReset
    0 Case 15: Flow reset, route change
    0 Case 16: Peer reset, route change
    0 Case 17: Peer Flow rejected, either WCC rejected or no egress port
    0 Case 18: Reset flow, bridge forwarding change
    0 Case 19: Reset flow, egress port went down
    0 Case 20: Client side connection reset sent
    0 Case 21: Server side connection reset sent
    0 Case 22: Reset client due to server reset
    0 Case 23: Received ACK to SYN, reset existing connection on server
    0 Case 24: Server side reset, server port down
    0 Case 25: Client side reset, client port down
    0 Case 26: Server side reset, client port down
    0 Case 27: Client side reset, server port down
    0 Case 28: MIDNAT reject, reset server
    0 Case 29: MIDNAT reject, reset client
    0 Case 30: FM_HandleTcpResetVipUnavailable
    0 Case 31: MID SPOOF reject, reset server
    0 Case 32: MID SPOOF reject, reset client
    Gilles.

  • Sendmail in Solaris 10 - 554 Too many connections from origin

    I recently upgraded a server from Solaris 9 to Solaris 10. One of the apps that worked fine on S9 is now having a problem. I believe I have discovered the cause, but I'm not having any luck coming up with a solution.
    The app in question queries a database for a list of e-mail addresses (all within our own domain) and then sends e-mail to each user. The messages are sent to our Barracuda firewall/spam filtering appliance, and it relays the messages on to our Exchange server.
    The problem that arose after the upgrade is that sendmail is opening too many concurrent connections to the Barracuda, and the 'Cuda is replying with "554 Too many connections from origin".
    I see that there is a sendmail configuration parameter "SingleThreadDelivery" that will only allow one connection to the Barracuda at a time. That appears to be overly restrictive, though.
    My question is this: is there a way to tell sendmail to only allow some number of concurrent connections to the 'Cuda so as not to hit this limit?
    Thanks,
    Bill

    Glen,
    Thanks for the reply.
    Yes, I did look at those, but my understanding was that those parameters effect inbound connection and in our case, the problem is that we want to limit the number of outbound connections.
    As it turns out, the S10 upgrade was not the cause of this problem. At the same time that we upgraded we also added a second network interface (and IP address). Unknown to either myself or the current Barracuda admin, the old IP had been configured into the 'Cuda so that rate limits did not apply. The fix was to add the second IP, too (well actually, he decided to open it up to all of our servers' internal IPs).
    Bill

  • I am not able to open itunes in my windows 7 i hav reinstalled it many times what can i do to open them

    i am not able to open itunes in my windows 7 i hav reinstalled it many times what can i do to open them

    Do you get an error message when you try to open it?
    W

  • HT201471 My wife got an ipad air model A1474 (WIFI only) in an airport shopping centre. She needed connectivity what can we do now to correct this mistake as the model is a mismatch for our environment in Nigeria where WIFI is not common

    My wife got an ipad air model A1474 (WIFI only) in an airport shopping centre. She needed connectivity what can we do now to correct this mistake as the model is a mismatch for our environment in Nigeria where WIFI is not common

    Mifi devices are usually quite small. Think Credit Card size, and maybe slightly thicker. So not really a big device you need to carry around.
    In any case if you are still within the 14 day return period you may be able to return it to an Apple retail store. It needs to be an Apple Owned store, not sure Authorized Resellers will let you do it.
    Other than that, bob points out, you may want to try to use the iPhone as a hotspot for the iPad.  If your Carrier supports it.  Like the Mifi device, the iPhone will share its cellular internet connection out to other devices over a Wireless network the iPad can use.

  • HT4061 my ipad is blocked, because I entered wrong password many times. what can I do

    my ipad is blocked, because I entered wrong password many times. what can I do

    Restore the iPad from the computer to which the iPod is synced. For information and instructions, see:
    http://support.apple.com/kb/ht1212
    If that will not work, you'll need to put the iPad into Recovery Mode and then try the Restore again:
    http://support.apple.com/kb/ht1808
    If that still doesn't work, as a last resort try DFU mode:
    http://osxdaily.com/2010/12/04/ipad-dfu-mode/
    Regards.
    Forum Tip: Since you're new here, you've probably not discovered the Search feature available on every Communities page, but next time, it might save you time (and everyone else from having to answer the same question multiple times) if you search a couple of ways for a topic, both in the relevant forums and in the Apple Knowledge Base, before you post a question.

  • IPhones w ActiveSync creating too many connections on mail server

    Over the past two days, I have started getting 503 errors, indicating too many connections. When I went to look at active connections, I noticed that the vast majority were from the iPhones that connect using ActiveSync. Just in the 45 minutes since I cleared all active connections, my iPhone has created 14 active connections. When you multiply that by the eight iPhones we have at this company the number jumps to 112. It is easy to see why the 503 error is getting generated by the end of the business day. It is as though the iPhone is unable to let go of an active connection, and just starts a new one. This only seems to be happening since the iPhone 3.0 update. Is anyone else experiencing similar issues?

    Yes - I'm having a very similar problem on our server. But in this case the user has a very large mailbox - and imap processes are spawned but never die unless I go in and manually kill them.

Maybe you are looking for

  • Cross tab reporting in Crystal 8.5

    Post Author: KPetrey CA Forum: General I am trying to create a cross tab report for some data that will have varying number of columns.I am running into a problem where some situations are producing 25 or more columns.  This results in the crossing o

  • IPhone will not sync with iTunes

    Ladies and Gents, I am having trouble syncing my iPhone with iTunes. A message stating that a "sync session could not be started" appears. Also when I try and check or uncheck boxes in the summary tab they go back to whatever they were before. When I

  • Why is the exponentia​l not working in TestStand?

    Hi, I am hoping this is a simple question to get answered... I have a values in dBm and I am trying to convert it into mW so I am using this equation in a statement line "Parameters.value_mW = 10^(Parameters.vaule_dBm / 10)" but the vaule it keeps gi

  • "Tabs" Tab is BLANK

    After a patch/upgrade, the "Tabs" tab is blank except for a few small dots near the top. Tried re-installing IND (without deleting first) to no avail. Any ideas? XP SP2, CS 1 (yes, I know it's old, but it works, mostly), IND ver 3.0.1

  • Copy a movie from iPad Air2 to Mac

    My girlfriend made a movie/video with her iPad Air2. Is it possible to copy this movie to my iMac although my iMac and her iPad don't "know" each other? What do I (or she) have to do so that we can exchange media? Thanks in advance