Have doubt?? Can any one clear it

Hi guys i have doubt.It will be nice if
some one clears it
around.
Question:
when making a connection to the database using
ConnectionPooling should we close
connection,statementobject and resultSet.
like this(this is the way i am doing too.)
try
---opening a connection,rs,stmt
other code
}catch() {
finally{
if(rs!=null)
rs.close();
if(stmt!=null)
stmt.close();
if(conn!=null)
conn.close()
Doubt:
Is it not Sufficient to close the connection.Can any one
explain in detail why resultset and statment should be
closed.

From my understanding, close releases resources on the object, so I would suspect that each DB driver implements their resources independently. It would be DB driver specific if closing the connection would cascade the resource cleanup to any objects that were created within that connection. I perform the same logic you do at the end of my DB calls. I have each in a try/catch since close throws SQLException, and I would prefer if each got the chance to execute. I don't do anything with an exception if close fails, because there really isn't anything you can do.
try {
      ...something to DB
}finally
   try {
       if(rs != null )
          rs.close();
   }catch(Exception e){}
   try {
       if(cursor != null )
          cursor.close();
   }catch(Exception e){}
   try {
       if(conn != null )
          conn.close();
   }catch(Exception e){}
}

Similar Messages

  • Can any one clear my dought's ?

    Here is a peace of code :-
    try
              Class.forName("com.mysql.jdbc.Driver").newInstance();
              con = DriverManager.getConnection("jdbc:mysql://localhost/project?user=root&password=swardfish");
              Statement st = con.createStatement();
              ResultSet rs = st.executeQuery("Select * from bill");
              while(rs.next())
              System.out.println(rs.getString(1));
              System.out.println(rs.getString(2));
              System.out.println(rs.getString(3));
              catch(Exception e)
              System.out.println("This Jsp File Not Working");
              }now what this line means & also ".newInstance()"?
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    newInstance Stand's For hear ?
    if i wan to use oracle then what queary i have to right ?
    & one more.
    i wana use MsAccess So can i use with java?
    if yes then pl tell me how i want to use withought JDBC:ODBC Connection so can i use it ?

    I award you full marks for originality of spelling.
    > Class.forName("com.mysql.jdbc.Driver").newInstance();It is roughly equivalent to doing this:
    new com.mysql.jdbc.Driver();
    newInstance Stand's For hear ?It doesn't stand for anything; it's a method on the class called java.lang.Class - see the API documentation for details.
    if i wan to use oracle then what queary i have to
    right ? [ ditto Access ]I think you need to read the tutorial:
    http://java.sun.com/docs/books/tutorial/jdbc/basics/index.html

  • Hi every one can any one help i have a problem in importing java dump for

    hi every one can any one help i have a problem in importing java dump for solman 4.0 mssql 2005 sr3

    Hi wahed,
    Please elobrate question not clear.
    Regards,
    Shahed iqbal

  • HT4436 I both have iCloud accounts and would like to share photo's etc. Can any one please advise if this is possible and how to do it?

    My wife and I both have iCloud accounts and would like to share photo's etc. Can any one please advise if this is possible and how to do it?      
    I have a Macbook-pro and Ipad, my wife has a much loved ipad.

    It's all described in iCloud Help here: http://help.apple.com/icloud/#mmc0cd7e99

  • Since itunes and apple tvs latest update I have had problem wtching movies on apple tv via my itunes can any one help, movie takes a very long time to load sometimes never, it use to work really well, whats going on please help?

    Since itunes and apple tvs latest update I have had problem wtching movies on apple tv via my itunes can any one help, movie takes a very long time to load sometimes never, it use to work really well, whats going on please help?

    You might find useful information in item D1 of Time Machine Troubleshooting.

  • Hello guys..!! I have got my new  iphone 4 2 days ago.The same day it got a problem of auto restart in every 1, to 2 minutes. I updated and restored it many times...but of no use... can any one help me how to solve this problem..!!

    Hello guys..!! I have got my new  iphone 4 2 days ago.The same day it got a problem of auto restart in every 1, to 2 minutes. I updated and restored it many times...but of no use... can any one help me how to solve this problem..!!

    Go to Settings/General/Reset - Erase all content and settings. the connecto to iTunes and restore as a New phone. Do not restore any backup. If the problem persists you have a hardware problem. Take it to Apple for exchange.
    This assumes that the phone is not hacked or jailbroken. If it is you will have to go elsewhere on the internet for help.

  • I am not able to register my Apple ID for iCloud and the error is "the maximum no of free accounts have been activated on this phone" can any one help me why I need to do

    I am not able to register my Apple ID for iCloud and the error is "the maximum no of free accounts have been activated on this phone" can any one help me why I need to do

    Sir, your Apple ID can be used as an iCloud account as well. They are both the same thing.
    You can learn more from --> Set up your Apple ID for iCloud and iTunes - Apple Support

  • HT204023 hi there can any one help me i have a iphone 5 but my mobile internet not working but i can connect to my wifi no bother

    hi there can any one help me i have a iphone 5 but my mobile data is not working but a can connect to my wifi no bother

    talk to your carrier about the data subscription and possible settings changes to their apn than

  • I'm not able to copy and paste files from my mac to hard disk and usb. I have tried dragging the items to those devices but it won't work. I also have tried copying and pasting those files onto those devices but that doesn't work too. Can any one help?

    I'm not able to copy and paste files from my mac to hard disk and usb. I have tried dragging the items I want to copy to those devices but it won't work. I also have tried copying and pasting those files onto those devices too but that doesn't work too. Can any one help?

    Hi BobRz
    Thanks for you suggestion but it didn't work - are there other ways for solving this problem? Or is it because my files that I want to copy and paste onto my hard disk etc are too big? (However there is space on my hard disk and it works on a PC)

  • I have MAC OSX 10.5.8 and need to install adobe illustrator. I checked the compatibility and found that CS5 will work.Can any one help where i can find it. The trail version is fine with me.

    I have MAC OSX 10.5.8 and need to install adobe illustrator. I checked the compatibility and found that CS5 will work.Can any one help where i can find it. The trail version is fine with me as i just have to use it for couple of days till i get my mac book back from service. Can any one help me on this.

    You are welcome, ameronweb.
    To elaborate a bit, you may come across offers of a new/unopened/unregistered version, which is the simplest case (you would need a guarantee). Other cases require much detailed information (and a guarantee).
    If upgrading to 10.6.8 or higher is an option, you could use CS6.

  • Have just down loaded Yosemite over Mountain Lion, Indesign CS5 does not work ( Am dependant on it) although Bridge , Light Room and Elements operate OK How do I solve this rapidly. Can any one help on this issue. Thanks

    Have just down loaded Yosemite over Mountain Lion, Indesign CS5 does not work ( Am dependant on it) although Bridge , Light Room and Elements operate OK How do I solve this rapidly. Can any one help on this issue. Thanks

    Sorry to say it, but I think you can see from Bob's response that there's no way to solve this rapidly.
    Did you take an image of your Mountain Lion install before upgrading to Yosemite? Roll back to that. If you're not in the habit of taking a snapshot of your system before performing operating system upgrades - get in that habit. If you are dependent on anything at all on hour computer, having a reliable backup method in place is essential. If you don't have a Time Capsule, or some other way to run Time Machine onto a disk that's not in your computer, go set that up yesterday.
    If you can't just remove Yosemite and roll back to Mountain Lion for whatever reason, you can partition your drive so that you can install both Yosemite and Mountain Lion on the same drive, and then boot into Mountain Lion when you need to work in CS5. Or you can take your Mountain Lion disc (I assume you have one, no?) and then use it to create a virtual machine in something like VirtualBox to run Mountain Lion from inside Yosemite.

  • TS1875 when trying to turn off compatibility mode on my itunes, i dont have a compatibility tab after right clicking properties. Can any one help

    When trying to turn off compatibility mode on my itunes i dont have a compatibility tab after right clicking properties. Can any one help???

    Hi Roger
    Thank you for your reply.
    My original feed is: http://casa-egypt.com/feed/
    However, because I modified the feed http://feeds.feedburner.com/imananddinasbroadcast and nothing changed, I redirected it to another feed and then I deleted this feed.
    Is there any way to change the feed in itunes? The only feed I have now is  http://feeds.feedburner.com/CasaEgyptStation
    I tried to restore the feed http://feeds.feedburner.com/imananddinasbroadcast but feedburner refused.
    I know that I missed things up but I still have hope in working things out.
    Thanks is advance.
    Dina
    Message was edited by: dinadik

  • I have a early 2008 macbook 13 inch and dont have the pass word can any one help?

    I have an early 08 macbook that is locked by password and do not know Itunes account. can any one help thanks.

    Upgrading to Yosemite
    You can upgrade to Yosemite from Lion or directly from Snow Leopard. Yosemite can be downloaded from the Mac App Store for FREE.
    Upgrading to Yosemite
    To upgrade to Yosemite you must have Snow Leopard 10.6.8 or Lion installed. Download Yosemite from the App Store. Sign in using your Apple ID. Yosemite is free. The file is quite large, over 5 GBs, so allow some time to download. It would be preferable to use Ethernet because it is nearly four times faster than wireless.
        OS X Mavericks/Yosemite - System Requirements
          Macs that can be upgraded to OS X Yosemite
             1. iMac (Mid 2007 or newer) - Model Identifier 7,1 or later
             2. MacBook (Late 2008 Aluminum, or Early 2009 or newer) - Model Identifier 5,1 or later
             3. MacBook Pro (Mid/Late 2007 or newer) - Model Identifier 3,1 or later
             4. MacBook Air (Late 2008 or newer) - Model Identifier 2,1 or later
             5. Mac mini (Early 2009 or newer) - Model Identifier 3,1 or later
             6. Mac Pro (Early 2008 or newer) - Model Identifier 3,1 or later
             7. Xserve (Early 2009) - Model Identifier 3,1 or later
    To find the model identifier open System Profiler in the Utilities folder. It's displayed in the panel on the right.
         Are my applications compatible?
             See App Compatibility Table - RoaringApps.

  • I have my brother i phone 5 but i dont have i cloud id or password i have serial number and all package the iphone can any one help me cuz i want open it please cuz my brother is dead sorry for time

    i have my brother i phone 5 but i dont have i cloud id or password i have serial number and all package the iphone can any one help me cuz i want open it please cuz my brother is dead sorry for time

    first i thank u
    but i just want apple id for his wife can remmber the password for the id he was have much more 5 apple id and i try to put them and i think u and apple can help us for we are older users of apple . them cant help us for just 1 time i have all package of phone the serial number and IMEI all of it . and thx u agine

  • Can any one tell me how to deactivate vendors in sap whom we have not done business for last 18 Month

    Can any one tell me how to deactivate vendors in sap whom we have not done business for last 18 Month>

    Hi Jahanzaib,
    You can go to transaction FK05 and block the vendor if you want to deactivate the vendors.
    Thanks,
    Ameet

Maybe you are looking for