HELP!! servlet stops working sometimes!!!

Can somebody please tell me what is wrong with the following code. Im starting to think it might be my sql statements. The servlet works correctly, but every couple days, when I run the servlet, it displays a blank page, and i have to upload the class file to the server again, then the servlet works. This is happening to a couple of my servlets, and I posted the problem on here several times, and each time I thought the problem was fixed, but it is not.
import java.io.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class byTown extends HttpServlet
Connection con = null;
Connection con2 = null;
public void init (ServletConfig cfg)
throws ServletException {
super.init (cfg);
try {
Class.forName("org.gjt.mm.mysql.Driver");
// Get Connection
con = DriverManager.getConnection ("jdbc:mysql://localhost/comperry_main","myusername","mypassword");
con2 = DriverManager.getConnection ("jdbc:mysql://localhost/comperry_main","myusername","mypassword");
}catch(ClassNotFoundException E) {E.printStackTrace();}
catch(SQLException e) {e.printStackTrace();}
public void doGet (HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
// Have browser ignore cache - force reload
// response.setHeader ("Expires",
// "Mon, 01 Jan 1990 00:00:00 GMT");
Statement stmt = null;
ResultSet result = null;
Statement stmt2 = null;
ResultSet result2 = null;
outline c=new outline();
try {
// Submit query
stmt = con.createStatement();
stmt2 = con2.createStatement();
result = stmt.executeQuery ("SELECT town,phnumber from towns where 1");
// Create output
PrintWriter out = response.getWriter();
out.print(c.header());
while(result.next()) {
result2 = stmt2.executeQuery ("SELECT COUNT(*) as mycount from business_info where (duplicateLink=-1 or duplicateyn=1) and (phone LIKE '%"+result.getString("phnumber")+"%' or Address1 Like '%"+result.getString("town")+"%' or Address2 Like '%"+result.getString("town")+"%') order by 'name'");
result2.next();
out.println("<a href=\"/servlet/myTown?ph="+result.getString("phnumber")+"\">"+result.getString("town")+" ("+result2.getInt("mycount")+" listings)</a><br>");
result2.close();
result.close();
out.print(c.footer());
out.flush();
out.close();
}catch(SQLException e){}
finally {   
try{
if(result!=null)result.close();
if(stmt!=null)stmt.close();
if(result2!=null)result2.close();
if(stmt2!=null)stmt2.close();
}catch(SQLException e){e.printStackTrace();}
public void destroy() {
super.destroy();
try{
con.close();
con2.close();
}catch(SQLException e){e.printStackTrace();}

hai,
JDBC Socket Connection is very costly, because of which everybody use a concept of Pooling the Connection.
The Instantiation of connection object itself takes more time and you never do that kind of coding like.
Go to Google Type "Connection Pool" and download a simpler ConnectionPool Source code and use it.
Or otherwise use the connection pool facility, if your server supports(The actual Impl/specifications are provided by sun , which is nothing but javax.sql.* packages), and I hope almost all javawebservers has a support to connectionPool, which are implmented according to Suns Specification( which would be the best,if u do).
If you use the above code, You will definitely suffer in future.
You should never close the connection, if you have written of your own connection pool (at any cost you should close result and statments).
but if you are using built-in Servers ConnectionPool , then close() method on DataSource Object is more like returning connection to the pool back, rather closing the connection.
You must make sure , that you are returning connections to the pool once after it is used(Normally , should be handled at finally blocks).
(Make sure, your databse supports auto commit facility, if so , do commit and rollback properly without fail, if you had set the autocomit to "false")
If you don't have any idea about Pooling, Please read on some good books
I recommend you, even almost all Collections classes should be pooled , since they are very costly and the instantiation time is more.
With Regards
Lokesh T.C

Similar Messages

  • PLEASE HELP!!! My 'Apple mobile device helper has stopped working'!

    Today i bought the new 3G iPhone so i went online to download the new 7.7 iTunes software. Now when i go into my iTunes a Windows pop up appears telling me that my 'Apple mobile device helper has stopped working' and that it is diagnosing the problem. The thing is that it doesn't diagnose the problem, the same box just keeps popping up over and over again.
    I am not very computer literate and have tried everything that i can think of but nothing has worked.
    Please can someone help because i'm absolutely dying to use my new iPhone; i queued up from 6 am to get my hands on it! :0(

    I'm just a simple user. I don't know how to fix it any more than any of the other posters with this problem. I've looked around in control panel, done some poking and prodding with services and processes, and can't find a reasonable way to stop the messages without completely hosing up iTunes. I know the messages are annoying as ****, and nobody likes the idea, but sitting around and doing nothing is sometimes a whole lot better then doing something that makes it worse. See if you can find a document from Apple that tells you how to go back to the previous version of iTunes. I've seen that course of action mentioned several times for previous releases of iTunes upgrades, so the instructions for it must exist in another forum.
    I just think, from the number of posts, that Apple is going to have to get a fix out pretty quickly, because this error pretty much shuts down their products on the Windows platform. They can't afford to let it go on for very long.

  • Why does the plug in stop working sometimes

    Why does the plug in stop working sometimes?

    Is your pc. laptop, whatever Windows -ana what version, like Windows Vista, or Windows 10.
    What bit is it? 32 or 64?
    You can get that info by right clicking on "My Computer" Uusually on the desktop) and selecting Properties in the drop down menu.
    And what version of Fire Fox are you using?
    And which plugin are you using, and is it for Flash Player?
    This info will help someone to answer your question.

  • Why does my wifi connection stop working sometimes?

    Hello.
    Maybe this has already been answered and I'm sorry but I didnt know what word to use in english to find the exact problem in google lol.
    Well, The problem is that my wifi connection seems to stop working sometimes, it takes about 1 to 10 min and then it just comes back. I can notice it because Safari stop to load pages, the appstore doesnt load, and I tried with google chrome : same results
    I experience this about 2 to 5 times a day, it's just pretty annoying. The wifi logo shows that it is always connected, it never shows that he is reconnecting
    May this be a router problem...? Or simply the computer
    My specs : 1,6GHz, intel core i5
    2go of RAM. It's a 2 years old MBA
    Thanls a lot !

    Hi CPUGenuis!
    I have an article for you that addresses this situation and will help you troubleshoot this issue:
    Wi-Fi: How to troubleshoot Wi-Fi connectivity
    http://support.apple.com/kb/HT4628
    Symptom: The network connection drops unexpectedly
    Your Mac may not not stay connected to your Wi-Fi network reliably.
    Your Mac may stop accessing the Internet during use.
    Solution
    Use these steps if your computer disconnects from its Wi-Fi network unexpectedly.
    Check your range to the Wi-Fi router and reduce the effect of interference.
    If your computer is too far from your Wi-Fi router or your environment has too much Wi-Fi interference, then your computer may not detect the Wi-Fi network properly. The easiest way to check for range limits with your Wi-Fi network is to move your computer or your Wi-Fi router closer together and make sure that there are no obstructions (such as walls, cabinets, and so forth) between the router and your computer.
    See Potential sources of wireless interference for more information about interference and solutions.
    Try connecting to a different Wi-Fi network. If your computer works fine when connected to a different Wi-Fi network, then the issue may be related to your network router or ISP. In that case, contact the manufacturer of your router or your ISP.
    Thanks for coming to the Apple Support Communities!
    Regards,
    Braden

  • "Mobile Device helper has stopped working" after installing most recent

    OK. Like a thousand other threads that have been posted over the past week or so on this topic and having tried most of the suggestions, I find myself at a loss.
    After most recent update (which I installed on Monday) from 3.1.2 to 3.1.3 all **** has broken loose between my *iPhone, iTunes & Outlook*. This all came to light just hours after the install. . . . I noticed that my phone wasn't syncing - at all, it just "hung" there then I went into my contacts in Outlook - gone. . . UGH, EEK, OK, so they're still on my iPhone BUT I can't get to them in Outlook. After loosing most of yesterday and all of today I am at the mercy of someone who might know how to resolve this issue.
    _*Steps I have taken :*_
    I have un-installed and reinstalled iTunes 5 times, no luck, I've restarted, yada yada yada. I've hidden my Norton's Internet Security, allowed iTunes, etc. *Still no luck*. Take in mind, all was great after months of perfect syncing, etc. no problems whatsoever . . .
    *The two messages that I continue to get when I open iTunes and connect my phone:*
    1) "Mobile Device helper has stopped working"
    2) " Unable to load data-class information from Sync Services. Reconnect or try again later".
    The most recent error message under "Problems Reports & Solutions" on my start menu read:
    Product: MobileDeviceHelper
    Problem: Stopped working
    Date: 4/7/2010 3:42 PM
    Status: Not Reported
    Problem signature
    Problem Event Name: APPCRASH
    Application Name: AppleMobileDeviceHelper.exe
    Application Version: 16.691.14.1
    Application Timestamp: 4ba3b8fe
    Fault Module Name: CoreFoundation.dll
    Fault Module Version: 1.550.17.21
    Fault Module Timestamp: 4b8cb530
    Exception Code: c0000005
    Exception Offset: 0000db6b
    OS Version: 6.0.6002.2.2.0.768.3
    Locale ID: 1033
    This is the same message that I have received the last 10 times under Mobile Device Helper.
    *Please PLEASE please*, does anyone know how to resolve this problem?
    *Thank you SO MUCH for any insight.*
    -signed, UGH!!!

    Hi,
    I have had the same experience... uninstalled and reinstalled iTunes and all Apple components only to now be in a position where I can't sync my iphone at all (before I started trying various solutions I could still sync music... now nothing!) and I continually get the messages "mobile device helper has stopped working" and then "iTunes was unable to load dataclass information from Sync Services. Reconnect or try again later".
    I even tried reinstalling iTunes 9.0 but somehow I don't have the old library saved - means I lose all the ratings, playlists etc.
    Really frustrating and disappointing.

  • Mobile Device Helper has stopped working

    I have just purchased an iPhone 3Gs, I have the lastest version of iTunes (9.1) and am operating on 32-bit Windows Vista using an Acer laptop.
    First, the iPhone was not recognised - so re-installed iTunes, downloaded Service Pack 2 for vista, reinstalled iTunes. Did't work. Finally found a forum that lead me to delete a problem file for Acer laptops (can't remember its name now) but then my iPhone was now recognised!
    Secondly, tried to sync my windows contacts (all my old contacta list from old phone) then had syncing problems..through more forums that error message stopped but now I have a new one that I can't get past...
    'Mobile Device Helped has stopped working' comes up repeatedly and will not let me to anything with iTunes as it freezes until I end task in Task manager.
    I have looked into other forums that talk of deleting the Apple Mobile Device, but it doesn't seem to me to be the rigt decision as the majority of people have just had to reinstall iTunes as it wont recognise the phone without the file.
    It seems that the new iTunes doesn't like Windows Vista.
    Please can anyone help me get past this point before I lose the will to live!! (it's been over 5hours now!!!!)
    Thanks

    Sort of the same issue.
    Windows Vista 64bit Home Premium.
    I just launched iTunes for the first time after installing 9.1. When I connected my iPhone, iTunes told me that I needed to install a newer version of Apple Mobile Device, which entailed removing/reinstalling iTunes and AMD. I remember there being an order to which applications should be removed, so I did that, but got stuck at AMD. I wasn't able to remove it. There was no error message, it just automatically rolled back the uninstall process and quit. I did some research and saw someone recommend using the Windows Install Cleanup Utility. I used that to remove AMD, and it worked. Next on the list was Apple Application Support (?), which also could not be uninstalled by normal means. So I used WIC on that as well. iTunes, Bonjour, Quicktime, and Apple Software update I was able to remove via the Control Panel. I rebooted, reinstalled iTunes, and when it began the install process for AMD I got this message:
    "Could not open key:
    Unknown\Components\DA42BC89BF25F5BD0AF18C3B9B1A1EE8\3F55235DF871F046A8F862841205 6EF. Verify that you have sufficient access to that key, or contact your support personnel."
    Got the same message for Apple Application Support. As a result, neither was installed.
    Prior to doing any of this, I had disabled AMD in Services, which didn't help. I have since re-enabled it, and it is still running in Services, although it does not show up in the list on programs to uninstall.
    After all this, I read in another forum that simply doing a Repair on AMD would solve the problem, but since I am unable to reinstall it, I cannot test it out.
    Message was edited by: Zachary Prewitt

  • Adobe Dreamweaver CC 2014 Helper has stopped working

    When I try to import an Flash SWF file created with CC 2014 I get an error that says Adobe Dreamweaver CC 2014 Helper has stopped working.  Then I get the option to check online for a solution and close the program or just a second option to just close the program.
    Any suggestions to a fix?

    I insured that Flash 64 bit was installed on my computer.
    This problem must have something to do with embedding a Flash file. I could not recreate the problem on other client's websites. I pulled all the Flash code and the problem went away. Of course I want to include a Flash file so it's still an issue for me.
    CODE I PULLED:
    <script src="Scripts/swfobject_modified.js" type="text/javascript"></script>
    <script type="text/javascript">
    swfobject.registerObject("FlashID");
        </script>
    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="100%" height="250px" id="FlashID" title="animatedDog">
                <param name="movie" value="dog.swf">
                <param name="quality" value="high">
                <param name="wmode" value="opaque">
                <param name="swfversion" value="10.1.0.0">
                <!-- This param tag prompts users with Flash Player 6.0 r65 and higher to download the latest version of Flash Player. Delete it if you don’t want users to see the prompt. -->
                <param name="expressinstall" value="Scripts/expressInstall.swf">
                <!-- Next object tag is for non-IE browsers. So hide it from IE using IECC. -->
                <!--[if !IE]>-->
                <object type="application/x-shockwave-flash" data="dog.swf" width="100%" height="250px">
                  <!--<![endif]-->
                  <param name="quality" value="high">
                  <param name="wmode" value="opaque">
                  <param name="swfversion" value="10.1.0.0">
                  <param name="expressinstall" value="Scripts/expressInstall.swf">
                  <!-- The browser displays the following alternative content for users with Flash Player 6.0 and older. -->
                  <div><img src="/images/2014/noFlash.gif" alt="Missing Adobe Flash player" /></div>
                  <!--[if !IE]>-->
                </object>
                <!--<![endif]-->
              </object>
             <br><img src="images/2014/sidePhotos/photo.jpg" alt=""><br>

  • My MacBook Pro is crashing and Mac OS stops working sometimes so I have to restart it. And sometimes it stays on the first white-ish screen with the Apple and won't start further. What to do?

    my MacBook Pro is crashing and Mac OS stops working sometimes so I have to restart it. And sometimes it stays on the first white-ish screen with the Apple and won't start further.
    What to do?
    Does that mean that the is the end of my Mac Book 5bought in the summer of 2009) ? Or is there someting to do to fix it?
    Thanks
    V

    Try this:
    How to Perform an Archive and Install
    An Archive and Install will NOT erase your hard drive, but you must have sufficient free space for a second OS X installation which could be from 3-9 GBs depending upon the version of OS X and selected installation options. The free space requirement is over and above normal free space requirements which should be at least 6-10 GBs. Read all the linked references carefully before proceeding.
    1. Be sure to use Disk Utility first to repair the disk before performing the Archive and Install.
    Repairing the Hard Drive and Permissions
    Boot from your OS X Installer disc. After the installer loads select your language and click on the Continue button. When the menu bar appears select Disk Utility from the Installer menu (Utilities menu for Tiger, Leopard or Snow Leopard.) After DU loads select your hard drive entry (mfgr.'s ID and drive size) from the the left side list. In the DU status area you will see an entry for the S.M.A.R.T. status of the hard drive. If it does not say "Verified" then the hard drive is failing or failed. (SMART status is not reported on external Firewire or USB drives.) If the drive is "Verified" then select your OS X volume from the list on the left (sub-entry below the drive entry,) click on the First Aid tab, then click on the Repair Disk button. If DU reports any errors that have been fixed, then re-run Repair Disk until no errors are reported. If no errors are reported click on the Repair Permissions button. Wait until the operation completes, then quit DU and return to the installer. Now restart normally.
    If DU reports errors it cannot fix, then you will need Disk Warrior and/or Tech Tool Pro to repair the drive. If you don't have either of them or if neither of them can fix the drive, then you will need to reformat the drive and reinstall OS X.
    2. Do not proceed with an Archive and Install if DU reports errors it cannot fix. In that case use Disk Warrior and/or TechTool Pro to repair the hard drive. If neither can repair the drive, then you will have to erase the drive and reinstall from scratch.
    3. Boot from your OS X Installer disc. After the installer loads select your language and click on the Continue button. When you reach the screen to select a destination drive click once on the destination drive then click on the Option button. Select the Archive and Install option. You have an option to preserve users and network preferences. Only select this option if you are sure you have no corrupted files in your user accounts. Otherwise leave this option unchecked. Click on the OK button and continue with the OS X Installation.
    4. Upon completion of the Archive and Install you will have a Previous System Folder in the root directory. You should retain the PSF until you are sure you do not need to manually transfer any items from the PSF to your newly installed system.
    5. After moving any items you want to keep from the PSF you should delete it. You can back it up if you prefer, but you must delete it from the hard drive.
    6. You can now download a Combo Updater directly from Apple's download site to update your new system to the desired version as well as install any security or other updates. You can also do this using Software Update.

  • RIM.Desktop Helper has stopped working

    Hi there,
    I just download Desktop Software v6 to my laptop HP window7 64 bit. when i installed, it open the WELCOME window and before i can press the Get Started button, it pop up another window saying RIM.Desktop Helper has stopped working  and the windows is checking but after that it closed.
    What should i do?
    Many thanks

    Hmm. That may be something in your calendar database is corrupt. Was your device ever synched before? There is a way of clearing the calendar database. So if you have your device synching with Outlook, after it's cleared from the BlackBerry, you could try synching again.
    To clear the calendar database you can go into Desktop Manager | Backup and Restore | Advanced. On the right hand side select the calendar database and hit the Clear button. Afterwards try synching again
    If someone has been helpful please consider giving them kudos by clicking the star to the left of their post.
    Remember to resolve your thread by clicking Accepted Solution.

  • My iPhone5 lock screen stops working sometimes

    My iPhone5 lock screen stops working sometimes.I have to restart the phone every time I encounter this problem. Sometime even when phone is locked and there's incoming call I couldn't answer simply because the touch stops working. This frequency of occurrence is increasing now.
    Is this some kind of software issue because I noticed this after updating to 7.0.2 iOS ?

    Because something is wrong with your iphone.
    Try the basics from the manual: restart, reset, restore.
    If these fail, it is likely a hardware issue.  Make an appointment at the genius bar.

  • Keep getting error installation helper has stopped working for readstep2

    keep getting error installation helper has stopped working for readstep2

    attach a screenshot of that error message, FAQ: How do I capture and post a screen shot or... | Adobe Community

  • Why does my "Click to tweet" button in Notification Center suddenly stop working sometimes?

    I like to compose tweets from the notification center in Mountain Lion, but recently whenever I click the button nothing happens. I tried unconnecting and then reconnecting my Twitter account and that doesn't work. When I restart my computer, it works for a while and then stops working again. Is this a bug?

    I know the ans...first install os x mountain lion again above all your installation..then see the build it should be.. (12c60) then..update every thing..but dont install or update..."update for macbook pro and macbook air 2.0 "it is the culprit ...then hide that update..and remember to install offline version of combo and supplement update 10.8.2..ok..as sometimes when ur notification cetre not work then installoffline "combo and supp" updates...ok..REMEMBER NOT TO INSTALL MACBOOK AIR AND MACBOOK PRO 2.0 UPDATE...PLZ...AND USE UR SYSTEM...!! follow me https://www.twitter.com/ankit8083   https://www.facebook.com/ankit8083...good luck..DONT CHANGE UR BUILD..AS IF U WILL CHANGE IT THEN UR SHARE BUTTON WILL NOT WORK..IN NEW BUILD..!!And wait for apple to get new build after april 2013...but not download macbook pro and macbook air 2.0 update..which help in graphical improvements and some usb devices...!!

  • RoboHelp7 - Micorosft HTML Help compiling stops working

    When compiling a help document for Microsoft HTL Help, very
    quickly in the compiling right after the display window says
    "starting compilation...", I get a MS window saying "Robohelp has
    stopped working" and wants to close the program. It's beena couple
    of days since I did a compile and I've added several topics. Any
    suggestions on what to check for?
    Thanks
    Mark
    using Vista with all the patches, RoboHelp 7 with it's latest
    patches.

    If your source has been on a network drive it may be too
    late. RH uses an MS Access database to keep track of the files and
    other elements of your project and these are known to have problems
    when run over a network. Sometimes you can end up with a corrupt
    file.
    What'd I'd do here is take a copy of the project. Then delete
    the topics you have added. Attempt to compile. If it works, the
    problem is with one of the created topics. Import each file in turn
    and compile after each one. This will determine which topic has the
    issue.
    If the project won't compile at all, try deleting the
    project's .CPD file. If this doesn't work, read and follow the
    instructions at
    this
    link..

  • My computer just stops working sometimes.

    Hello, About 2 times a day when i'm using my computer it will just stop working. It will not close anything i have open, but it will not enable me to use them. For example ill be listening to Pandora on my desktop and Google chrome(and explorer) will stop
    playing the music and will just sit there. I close the window and try to open it again, and it lights up on the task bar like its about to open, then it just slowly fades and never opens. At this point i go for the restart button and sometimes that does not
    work, and i cant access anything so i'm forced to hold the power button then it works for a while after that. Please help me, this is getting very frustrating.

    Hi,
    We could take use of Windows Performance Recorder to troubleshoot Windows performance issue, more details and the steps, please check the blog below:
    Troubleshooting Windows Performance Issues Using the Windows Performance Recorder
    In addition, please also take a look at the following article and follow the advices to improve Windows Performance:
    Performance & maintenance
    If any further questions, please feel free to ask.
    Best regards
    Michael Shao
    TechNet Community Support

  • Lumia 520 - Internet stops working sometimes. Nee...

    I have been using a Nokia Lumia 520 for 6 months.  Sometimes the internet stops working.  Only after removing and replacing the battery, the problem is resolved.  It happens say 2 or 3 times a month.  Is this a common problem?  Does it indicate a problem with the hardware or software?
    Thanks
    Solved!
    Go to Solution.

    Switching the phone off doesn't really switch it all the way off, it just puts it into a kind of "sleep" mode, but the O/S is still running. How would it know that you've pressed the power switch otherwise? Even if it's interrupt-driven rather than the switch being polled constantly, the CPU still has to be running to register the interrupt (see http://en.wikipedia.org/wiki/Interrupt for a description of what an interrupt is).
    By pulling the battery out you're forcing the phone to shut down completely. There's no way it can continue to run without power.
    Was this post helpful? If so, please click on the white "Kudos!" star below. Thank you!

Maybe you are looking for

  • My macbook pro early 2012 won't install release version of yosemite after being in the beta test

    my macbook pro early 2012 won't install release version of yosemite after being in the beta test, anyone else having any issues with this?

  • HTTP error [403] in "Add Forums Administrator User"-iView (Forum)

    Hi All, I need help with installing the forum functionality. When I open the "Add Forums Administrator User"-iView I always get the following error message: <i>403   Forbidden You are not authorized to view the requested resource.</i> In the log-file

  • System identifica​tion for open loop unstable plant?

    Hello, I have been trying to use system identification on labview. My problem is that my plant is open loop unstable and none of the tutorials or examples I have found seem to cover this so I cannot get it to work. Does anyone have any suggestions as

  • Passing values in "Date Entry" items to called page

    I have a page with: o 2 Date Entry fields (P1500_BEGINDATE & P1500_ENDDATE). o A "Submit" button, P1500_SUBMIT_DATE_RANGE I want to use the 2 dates in a query on a linked page, called by the Submit button. I've setup 2 hidden Date Fields on the 2nd p

  • WBS in Planning Board

    Dear All, Need help in understanding how and when will the % duration of work which we get while confirming an acitivty will show up in higher WBS. Eg.        WBS level 1                                   % duration of work doesnt show up (no time ba