MySQL Connection too slow

Please anyone with expirience in applets accessing MySQL Server!
I made a test with a loop code executing queries and got the following conclusion:
In media a query takes more than 2 seconds. I used PrepareStatement for better performance but it doesn�t make it better. I�ve heart about persistent connection. It�s realy faster? You know anything I could do for better performance? Obs.: When I ping my server the time answer is 200 ms. I�m from Brazil. But I think it sholdn�t make the mysql too slow as it is. Please help me.....
I�m very thank for ur help..
My java code:
     public void ConectaBD()
          try
               Class.forName("com.mysql.jdbc.Driver").newInstance();
               //Class.forName("org.gjt.mm.mysql.Driver").newInstance();
          catch(Exception e)
               System.out.println("Error: " + e);
          try
               con = DriverManager.getConnection("jdbc:mysql://labinfor.com.br/labinfor_codvirtual?user=labinfor_cliente&password=800091");
          catch(SQLException e)
               System.out.println("Error: " + e );
               e.printStackTrace();
public void Logon()
               java.util.Date start = new java.util.Date();
               long startTime = start.getTime();
if (ValidaCPF(TFCPF.getText()))
queryLogon = "SELECT Nome FROM clientes WHERE CPF='" + TFCPF.getText().trim() + "' AND senha='" + TFSenha.getText() + "'";
int indCon=0;
Timer t = new Timer(1000, this);
t.start();
while(indCon<100)
     Conecta();
     try
               stmt[indStmt] = con.createStatement();
     rsLogon = stmt[indStmt].executeQuery(queryLogon);
     Achou = "false";
     while (rsLogon.next())     
     Achou = "true";
     StrNome = rsLogon.getString(1);
     LValidaCPF.setText("Bem-vindo " + StrNome);
     TFCPF.disable();
     TFSenha.disable();
     BLogon.setLabel("Logoff");
                                   System.out.println("delay["+indCon+"]= "+System.currentTimeMillis());
     if (Achou == "false")
     LValidaCPF.setText("CPF ou senha incorreto");
     Desconecta();
     catch(Exception e)
     System.out.println("Error: " + e);
     indCon+=1;
}

Connection times of 1 to 5 seconds are normal. Pool your connections.
To understand why:
First, setting up a TCP/IP connection takes roughly 50% longer than a ping; a ping is one packet to the server and one packet back, a TCP/IP handshake to create a connection is one packet to the server, one back, and another to the server. Then you have a required brief wait before the connection is considered complete; we'll ignore the wait and call it .3 seconds for the TCP/IP handshake.
Second, the database has to go through the login process. Just sending the login request and response is yet another packet round trip; in your case, that's another .2 seconds in just network time alone. With MySQL, the login involves checking the security of the connection and the user; it often requires a reverse DNS lookup on the IP address of the client. Probably 4 or 5 tables have to be queried and a user environment is created within the server. The server work for the login might take .75 seconds, at a guess. Adding the network time makes this step .95 seconds or so.
Third, there's the time it takes to do the query itself; another network round trip; .2 second network round trip, plus maybe .1 second to run the query on the database, for a total of .3 seconds.
Fourth, there's the time it takes to tear down the TCP/IP connection on connection close. That involves 4 packets, 2 round-trips, so add another .4 seconds.
Adding it all up, you get .3 + .95 + .3 + .4 = 1.95 seconds, of which .3 is your SQL query (network and DB time), .9 is network time for TCP/IP connection and login request, and .75 is DB time for the login.

Similar Messages

  • Why is the same wirelles connection too slow for an iphone4 when it is quite fast to an iphone5?

    Why is the same wirelles connection too slow for an iphone4 when it is quite fast to an iphone5?

    You really have a question for iPhone support here, so I suggest that you post in the appropriate support area:
    Using iPhone
    The experts over there will likely suggest that you use the Apple Troubleshooting Guide for iOS devices, so you might want to work your way through that before you post in the iPhone support area.
    http://support.apple.com/kb/TS1398

  • Internet connection too slow, is there a way to speed up the itouch?

    So I can connect to Facetime, but all I see is a picture of a person and then the Itouch freezes and shuts down. I think it is because my internet connection is too slow, because it only doesn't work in my apartment (it works at places with quicker connections).
    The question is, is there currently a fix to this problem (I can't be the only one who has it)? It all works, just freezes after connecting and showing the picture of the person I'm talking to then disconnects. Is there a way to make this work?
    I'm at college and the only reason I got the 4g from my parents is 'cause they wanted me to help my little bro with homework back home... but if Facetime doesn't work at college then I should sell mine and go with a cheaper, earlier generation. Thanks!
    Message was edited by: ClassyCoug

    By what type of security I mean, WEP (not preferred), WPA, WPAs. I would go to the support page for you router on the manufacturer's sit to see if an update to the firmware is available. You also have to enter the setup for the router to determine the installed version of the firmware. Not infrequently a firmware update fixes problems since that is one purpose of the updates.

  • Dial up connection too slow

    Server:linux
    databse:9i
    Jinitiator 1.3.1.13
    We try to connect to our application using dial up connection
    ,it was too slow to initiate jinitiator
    ,how can i solve this problem

    Hi baxel, try from your library computer to download from the next link :
    https://www.mozilla.org/en-US/firefox/all/
    then put it on a flash drive and install to your home pc.
    the above link with all languages and systems (windows, Mac OS X Linux) exist also in mozilla.org in green box as Systems & Languages link.
    thank you

  • DataSocket connection too slow

    Hi everyone
    Am using DataSocket server to communicate between various application over the network, some of the application are programmed using Labwindows CVI and some of the data acquisition application are programmed using Labview.
    When the CVI application is started the DataSocket server is connected almost instantaneously, but the labview applications connect very slow almost takes a minute, and the DataSocket server hangs till all the connection are not established. the labview applications are running in embedded controllers NI PXI 8186. Am using 8 dataitems in each labview application and there are 4 such applications.
    so when all of the application are started at a time the problem is more severe, can any one tell me how is that i can improve the connection speed?
    Thanx for the reply.
    regards
    Arun

    hi there
    be sure to use the Open/Close Connection functions. see attachment.
    Best regards
    chris
    CL(A)Dly bending G-Force with LabVIEW
    famous last words: "oh my god, it is full of stars!"
    Attachments:
    DSTP_IO_7.1.vi ‏24 KB

  • Saying connection too slow for shareplay,but i have really good speed

    i have a really good speed ,when i start shareplay with someone it says that i have very low speed.i have like 3mbps(upload) and 7mbps(download or whatever)mabey its because of the update...please fix this or help! 

    SharePlay can be a bit temperamental at times. The best connections can sometimes say your speeds are too sow. While the slower connections can say the opposite. It has it's moments.
    Do a Test Internet Connection in the PS4 settings. Then try it again a minute later. You'll have quite different results sometimes
    If it allows you to continue, then just do so. Altough your speeds may result in some poor image quality and lag for the person your SharePlay'n with

  • BEFW11S4 wired connection too slow

    My ISP provided advertised speed is 8Mbps. Direct connect to modem I measure 8.5Mbps. Wired connection to router only runs at 4.1Mbps. I am lastest firmware for this version. I am using DHCP to obtain IP from my ISP.
    Please advise.

    Your router was designed back in the days when 1.5 Mbps was a fast Internet connection.  It's not built for today's higher connection speeds.   If you worked on it, you might be able to get your BEFW11S4 up to 5 or 6 Mbps, but probably not more than that.
    It's time to buy a new router.
    Here is a web site that claims that they can measure the "WAN to LAN" speed of a router:
    http://www.smallnetbuilder.com/component/option,com_chart/Itemid,189/

  • I just brought a brand new Macbook pro retina display, when i connect it to my apple tv through airplay its too slow and when it try to play a movie apply tv is always a minute or 2 behind. How can i fix this?

    I just brought a brand new Macbook pro retina display, when i connect it to my apple tv through airplay its too slow and when it try to play a movie apply tv is always a minute or 2 behind. How can i fix this?

    Hello HanaAmer1,
    We've an article which provides troubleshooting steps that can help get AirPlay workign correctly.
    iTunes: Troubleshooting AirPlay and AirPlay Mirroring
    http://support.apple.com/kb/TS5209
    Cheers,
    Allen

  • I have an ipad3(wifi  cellular). Now i want to upgrade my iOS5.1 to ios 7. But download speed in our country is too slow(100kbps). It can be disconnected anytime. Is there any problem if net connection get disconnected while upgrading ios? Please ans me.

    I have an ipad3(wifi +cellular). Now i want to upgrade my iOS5.1 to ios 7. But download speed in our country is too slow(100kbps). It can be disconnected anytime. Is there any problem if net connection get disconnected while upgrading ios? Please ans me.

    haha, so now i'm thinking. I'm learning the terminal as fast as i can but there are several lines of codes and commands in there that throws up red flags to me that i don't fully understand. It just looks fishy too me. It would be highly appreciated if someone could just check this out just to tell me that i don't need to worry about it. Or point me in the right direction. I just feel un easy about this. ha.

  • I'm on a prepaid plan for the 4s, i want the hotspot option which isn't offered on the prepaid plan.  heard the connection is too slow on the 4s only worth it on the 5 or 5s. would you agree? not sure how much the hotspot would increase my monthly bill...

    i'm on a prepaid plan for the 4s, i want the hotspot option which isn't offered on the prepaid plan.  heard the connection is too slow on the 4s only worth it on the 5 or 5s. would you agree? not sure how much the hotspot would increase my monthly bill....

    To use the hotspot for any of those devices, I believe you have to switch to a postpaid account and plan. You can see the pricing for the available postpaid plans under the "Shop" area of the website.

  • After updating to 4.3 I can't connect to wi-fi because the "internet speeds are too slow". How much speed does this require?

    After updating to 4.3 I can't connect to wi-fi because the "Internet speeds are too slow". So what speed does it need?

    I called tech support and I got the same **** canned response, backup and reset to factory settings.  Yeah right!  Everything was fine until Verizon shoved the software update down my throat.  I finally unchecked the box in Wi-Fi settings for auto network switch.  However, I still get the "Your Internet connection is unstable" warning no matter what Wi-Fi connection I hit.
    In a related story, I received a new or refurbished phone as my original SIII had AC/charging connection issues.  I called probably three times to attempt to back up my data, went into two stores in attempts to have them transfer the information over, and all were too incompetent and inept to assist me.  Only when talking to someone about this Wi-Fi issue, did someone actually know how to back up everything.  Of course by this time, I had to send the new phone back because Verizon charged me $400 before I got everything squared away.  What a colossal waste of my time!

  • HT1766 I have an ipad3(wifi +cellular). Now i want to upgrade my iOS5.1 to ios 7. But download speed in our country is too slow(100kbps). It can be disconnected anytime. Is there any problem if net connection get disconnected while upgrading ios? Please a

    I have an ipad3(wifi +cellular). Now i want to upgrade my iOS5.1 to ios 7. But download speed in our country is too slow(100kbps). It can be disconnected anytime. Is there any problem if net connection get disconnected while upgrading ios? Please ans me.

    There is something Definitely wrong with iOS 7 regarding DATA USAGE being logged to wireless carrier in for WIFI instead.
    I read all the previous replies and same issue.
    I rarely use my mac to sync....its all wifi sync for the last 2 years....never had this issue before... and i know it began with iOS7.... here is why....
    My iPhone was at home when I updated to iOS7 connected to wifi...but it logged Data Usage to Rogers Wireless (700MB approx)...data will never do an update over 50mb in app store (it gives the warning to use wifi) I play a lot of games and pay for them so I always update through App Store.  2 weeks later, simposons halloween update (650mb)...at home, using wifi.
    Rogers told me there was 700+mb data usage on the day of update and 650+mb data on oct 1.st (tapped out).
    Went over my 6GB plan and paid the fees.
    This has never happened before...It must come to apples attention by now...

  • How can I make Time Machine use the ethernet cable to Time Capsule instead of the wireless connection? Wireless is too slow; has been taking 40 hours to create an initial 142 GB backup.

    How can I make Time Machine use the ethernet cable to Time Capsule instead of the wireless connection? Wireless is too slow; has been taking 40 hours to create an initial 142 GB backup.

    Plug in ethernet .. in the computer.. turn off wireless.

  • I am U.S. iPhone 4S user traveling in China.  Data speed is too slow to be usable.  Verizon says that it because iPhone 4S connects to strongest signal even if slowest.  Any work arounds for this design flaw?

    I am U.S. iPhone 4S owner traveling in China.  Data speed is too slow to be usable.  Verizon says that is because iPhone 4S connects to strongest signal, even if slowest (virtually non-existent) data network.  Does anyone know how to work around this design flaw?

    I spent 2 months in china with my old iphone 3gs.  Both China Unicomm and China Mobile were accessible through my US phone.  (for you other users, yes my phone bill was sky high, but it's a small price to pay when you get instant access to your wife while you are gone... and to be able to use the google translate app).  I had a GSM phone (obviously) and had the ability to choose what carrier I wanted my phone to connect to (the same thing was available when I was in italy as well). 
    it was under
    general-> network> then there was a new field (that does not normally show up when in the US) that listed the available networks to connect to.  my phone always attempted china unicomm first, and switched to china mobile only when unicomm was unavailible. 
    but if wjosten is correct (and i imagine he is), cdma phones may not be able to choose what network to connect to. 

  • HT4061 After latest software update(IOS 5.1.1), connectivity is too slow on Ipad

    After I upgraded my iPhone 4 and iPad 2, network connectivity or connectivity as a whole is too slow. Almost all the Apps dies with time out. Is there a solution to this? This problem persists in wifi as well as 3G network.

    3G is painfully slow since the 5.1.1 update for me too. Turning off wi-fi seems to help some, but it's still noticeably slower. I hope apple is working on a patch or I'll be trying to restore back to 5.1 which ran fine.

Maybe you are looking for

  • ThinkCentre E73z integrated camera cannot be used in Skype

    Hi, I have just finished the complete updating of the preinstalled windows7 professional on my new ThinkCentre E73z. This is the first use. I'm very disappointed. When I installed Skype it says that Skype can't detect any Webcam. They offer to buy on

  • How to create a check box with an X

    Hi, How do you create a check box with an X as apposed to a tick? Thanks

  • Imac G4 black screen - darwin/BSD??? bash - 2.05a$

    Wow what does this mean!!?? We were installing the operating software when we were asked for a password, we had to reset password which we did, started up the computer again, got to log in screen, entered password and then............ black screen co

  • Third party encoding for use with iDVD?

    Hello All, I have been doing a little bit of research on this, but I think I need some answers from more experienced users. Are there any third party apps that do a better quality job of encoding video for use with iDVD? I edit my videos in Final Cut

  • Unable to test WebDynpro Application

    Hi, I am learning WebDynPro Application development by installing SAP NetWeaver 7.1 Demo System from SDN. I am able to view the Views as Preview in SE80 Layout TabPage and they work fine. But an activated WDA wont show up on my browser. I seem to be