Statement / Connection  Which is better

Howdee. Those that have been reading my posts will know what this is about ;-)
In this app I am updating a java.sql.Connection is created at the beginning of the appiication. A Statement object is created from that. That single Statement object is passed around to the elements of the application.
It is a single Thread environment ( as far as using the Statement Object).
Is it better to use that one Statement object over and over or should the application use the single Connection object and createStatement() for each call.
I would think the first option would be fine since you will be cutting down on method calls to create a new Statement() over and over.
Am I insane (again)

Keeping a statement object open will probably reserve some resources on the database server (depending on the database vendor). So i would only keep the statement object around for short bursts of work, and throw it out when you aren't going to use it right away, and recreate it.

Similar Messages

  • Why assertion instead of if statement ?  Which is better to use ?

    Why assertion instead of if statement ? Which is better to use ?

    Never assertion instead of if statement. The two have fundamentally different intents. Using assert to control program flow is a bad idea

  • Network connection, which is better?

    I will be adding a MAC Pro Tower, dual quad 8, to my wireless network this week. At present, I have one wired connection and 3 wireless connection on my d-link n-protocol network. My question is this:
    Should I connect the MAC computer wirelessly or wire it to my router? I will realize faster download and upload times if I do it wirelessly (I think), but this is where I need expertise.
    Thank you for your help.

    I tend to agree with "Fortuny". My Mac Pro is hard wired via an Ethernet port to my Airport Extreme base station while my MacBook Pro and my wife's iMac are using wireless connections to the internet. Although both are quite reliable in my area, there have been times when the wireless connection has been marginal but my Ethernet connection has always been solid as a rock.
    Good luck.

  • Import Statement - Which is Better ???

    Which import statement is better? Are there any performance advantages of calling the ones you need explicitly instead of using the shorthand (.*)?
    import java.util.*
    or
    import java.util.Vector;
    import java.util.TreeMap;

    there is no runtime performance difference. There could be a difference in compliation time if you use wildcards, but even that difference would probably be insignificant (plus, is compile time usually a concern in java?). The main advantage to importing only the classes you need, as the previous poster pointed out, is to reduce compilation ambiguities (e.g. does 'Date' refer to java.sql.Date or java.util.Date). For example, a recent poster just reported a problem where he imported java.beans.* and java.sql.* and, after upgrading to 1.4, none of his code compiles because both packages now have a Statement class, which causes ambiguities. As a general rule, it is best to import only the classes you need.

  • HT1178 I have BT Infinity at home with the BT modem connected to the phone line and then to a BThub which delivers the wif signal. I have purchased an airport extreme to improve wi fi strength if how do I connect up to hub it states connect modem to WAN o

    I have BT Infinity at home with the BT modem connected to the phone line and then to a BThub which delivers the wif signal. I have purchased an airport extreme to improve wi fi strength if how do I connect up to hub it states connect modem to WAN on back of Airport Extreme.
    Instructions do not mention connection to BT Hub and the BT modem has only one output which you dicsonnect from Hub and connect to airport extreme leaving. Once you do this Hub has no signal.
    How do I rectify
    Paul

    you can also set up the Airport extreme to extend the wireless by hitting the wireless tab in the airport menu then click the drop down menu to select extend
    Apple's "extend" function is a proprietary setting that was designed to only work with other Apple routers.
    It would be extremely unlikely that this setting would work with a BT product, or any other manufacturer's product for that matter.
    But, I haven't tested this with a BT product...and I suppose anything is possible.
    Still, I would be extremely surprised if this worked.
    The AirPort Extreme might "join" the BT network if you try this......but the AirPort does not provide any additional wireless signal coverage when it "joins" a wireless network. In fact, it really does nothing when it "joins" a network except enable the USB port.

  • Connecting MAC Air to Projector - which is better, hdmi, vga or usb?

    Connecting MAC Air to Projector - which is better, hdmi, vga or usb?

    HDMI is thje preferred digital replacemnt for older analog video standards, which your other choices use. It offers far higher signal and definition quality.
    Apple has an adapter that is used with your Thunderbolt port/ Mini DisplayPort, if yours is equipped as such.
    I've not had a problem with this. It is a Belkin.
    http://store.apple.com/us/product/HA824ZM/A/belkin-mini-displayport-to-hdmi-adap ter?fnode=51

  • What USB 3.0 card should I get for early 2009 Mac Pro so I can connect the Drobo 5D? They say get CalDigit or Sonnet. Anyone have preference or experience with reliability. Trying to find which is better.

    What USB 3.0 card should I get for early 2009 Mac Pro so I can connect the Drobo 5D? They say get CalDigit or Sonnet. Anyone have preference or experience with reliability with this. I am running Lion and Trying to find which is better as I know from experience not all cards are created equal. Thanks in advance for your help!

    yakov536 wrote:
    High Point RocketU Quad USB 3.0 for Mac is working great for me. Had an issue with CD/DVD Drive which was resolved with most current driver downloaded from the support site.
    Running Moutain Lion on Early 2009, mirroring two Seagate Go Flex 2TB USB 3.0 Drives. Installed in Slot 4.
    Using it primarily with VMWare Fusion for Virtual Drives. Windows, Unbuntu and other OS running really well.
    HPT Support was responsive and very helpfull using the WEB Portal under the product page.
    I have some comments and a suggestion:
    Have you tried your setup with a SD/CF combo card reader (like the Lexar or Kingston FCR-H63)? Does the card appear on the desktop when first plugged in?
    Did you need to fool around with any kind of power issues in installing this card in the x4 PCIe slot of the MacPro?
    Suggestion. Have you tried one of the fixed in this article to cure the BT issues in MacPro 3,1?
    Good luck.
    Henry

  • Which is better to use: BEx query or Web Application as an iView in portal?

    Hi gurus!
    Are there any experienced opinions, which is better - publish a BEx query in portal or publish a BEx Web Application in portal? Is it easier to alter the layout attributes etc. if I create a BEx Web Application first before publishing?
    What is the way of fixing for example filter item height if I publish BEx query in portal - is there a Web Application that it uses anyhow which I can fix? Or can I use in that case iView -properties in portal?
    Thankful for advice
    Sari

    ok, means i can use jsp:useBean tag for all my
    classes that are not actually bean. so it will be
    instantiated at run time and provide efficiency .No. Jsp:useBean is used for java bean components.
    >
    but when should i use import statement in my jsp and
    it happen at translation time so will it create any
    type of burden for my code if i import multiple
    classes.For non-java beans, you need to import the classes, period.
    It's not a burden, it's a necessity.

  • Which is better, Netgear N900 or Airport Extreme?

    Which is better, Netgear N900 or Airport Extreme?

    Gpcn,
    I'm going to highly recommend the new Airport Extreme. I've been having all sorts of wifi and networking issues because of the saturated 2.4 GHz spectrum in my surrounding neighborhood.
    I finally bit the bullet on friday night and purchased the Airport Extreme. I could not be happier!
    I used to top out at around 8 Mbit/s download and 1 Mbit/s upload with my older Linksys setup. Now i'm getting 40+ Mbit/s and 2 Mbit/s respectively.
    Not only that, but i'm no longer dropping my wifi with my devices (latops, iPads, iPhone, etc). It's very consistent and the speeds are amazing!
    Sure it may be pricier than others, but it's worth every penny. The setup is very easy and you get Three Gigabit Ethernet LAN ports for connecting computers or network devices as well as built-in NAT support for security. You are better off getting the Airport Extreme.

  • ACE 4710 - show stats connection questions

    Hi,
    I have three questions regarding the "show stats connection" command in the ACE 4710:
    1. What is the criteria for a connection to be added to the "Total Connections Failed" counter?
    2. What is the criteria for a connection to be added to the "Total Connections Timed-out" counter?
    3. Is there a command to get more information why the connection was failed or timed-out (e.g. to/from which IP, url accessed etc.)?
    Thanks in advance for your help!
    Best regards,
    Harry

    Harry,
    a connection failed if the server did not respond or resonded with a RST.
    As long as the connection gets establised, it is counted as a success.
    The connection timeout counter is incremented when the connection is idle for the configured timeout value or for L7 connections if it does not complete the 3-way handshale within the embryonic timeout interval.
    Since this is clear why those counters are incrementing, the only way to get more information is to capture a sniffer trace to verify if the conditions above are met.
    Gilles.

  • Coding Preference ..Which is better for memory?

    Hey all,
    Javas garbage collection is sweet. However, I was reading somewhere that setting some objects to null after I'm done with them will actually help.
    (help what .. I'm not sure.. my guess is memory used by the JVM)
    Thus I have two ways to do the same thing and I'd like to hear peoples comments on which is "better" ... or will yield faster performance.
    Task: I have a Vector of Strings (called paths) that hold absolute file paths. (Don't ask why I didn't use a String[]) I'd like to check and see if they exist, and if not, create them... I'll use the createNewFile() method for that.
    Method A -- Here I'll reuse that File object
    public void myMethod()throws Exception{
    File file = null;
    for(int i = 0; i < paths.size(); i++){
      file = new File(paths.get(i).toString());
      boolean made  = file.createNewFile();
      if(made){doSomething();}
    file = null;
    }Method B -- Here I'll use um... "dynamically made" ones that I won't eventually be set back to null
    public void myMethod()throws Exception{
    for(int i = 0; i < paths.size(); i++){
      boolean made  = (new File(paths.get(i).toString())).createNewFile();
      if(made){doSomething();}
    }So when the code eventually exists myMethod, the object "file" will be out of scope and trashed.... correct? If thats the case, then would there be any other differences between the two implementations?
    Thanks

    There's no real difference between the two. Choose the style you prefer,
    although in the first one I'd lose the "file = null" statement since that
    variable is about to disappear, and I'm move the definition into the loop
    -- always give variables as small a scope as possible, mainly to
    keep the logic simple:
    public void myMethod()throws Exception{
        for(int i = 0; i < paths.size(); i++){
            File file= new File(paths.get(i).toString());
            boolean made  = file.createNewFile();
             if(made){doSomething();}
    }

  • Hughes net vs Wildblue which is better.

    I am considering Satellite internet service.  I live in a rural location where this is the only thing other than dial-up.  Which is better Hughes net or Wildblue?  Second, I need to be able to monitor my dog (live) from a remote location.  What camera would service this best using a satellite internet connection with stated upload speed of 128k.

    Neither. They both cap your bandwidth each day
    *******DISCLAIMER********
    I am not an employee of BBY in any shape or form. All information presented in my replies or postings is my own opinion. It is up to you , the end user to determine the ultimate validity of any information presented on these forums.

  • Singleton vs static - which is better?

    Of the two approaches -
    a class which can be used by accessing its ONLY instance(singleton) or a class which has a set of static methods which can be invoked on the class itself
    which is better and why? Or are these just two 'styles' of programming?
    I always get confused as to which way to go? I tend to prefer to have static methods on the class instead of a singleton.
    All insights/comments/ideas welcome.
    Thanks

    Well, there are a few questions you can ask - does the method cause any changes of state, or is it a pure function? If the latter, static is probably the way to go.
    The way you are talking, I gather that there is some state involved.
    Next question: does it make sense for there to be more than one of these per JVM? Not only in the way you currently envision it, but at all, anywhere. For example, consider the list of Strings that the String class keeps so it can consolidate memory and avoid duplication (see String.intern() ). That list makes sense to be static.
    On the other hand, the representation of the state of a board game should not be static, because someone could want to write a program which has multiple games within it - or you could within one game wish to have contingencies or undo-ability (essentially, it might not be as singleton as you think).
    Next, if you think the methods will ever need to be overridden, use a singleton, because static methods aren't, well, dynamic! (in case the singleton is a one-at-a-time singleton but it makes sense to have a change of identity over time).
    I have never written a true singleton - though often written classes which I did not PLAN on instantiating more than once.

  • Which is better,the Apple TimeCapsule or the WD MyCloud for backing up pixs and datas?

    I am not too sure which is better for backing up my pixs that i have saved and dont want to lose them,am thinking which would be best for me to purchase?the apple timecapsule or the wd mycloud,i heard great things about both but not sure from someone who got experience,so could u help me out and tell me which is better and why?
    thanks in advance...

    Backup is backup. Doesn't matter how you do it, but that you do it.
    Given the choice you posited I would choose the Time Capsule if you want to use Time Machine. If you wish to use third-party backup software then you can only use the WD. It comes with its own proprietary backup software. Or you can go another direction and avoid cloud/network backup which is very slow.
    Basic Backup
    For some people Time Machine will be more than adequate. Time Machine is part of OS X. There are two components:
    1. A Time Machine preferences panel as part of System Preferences;
    2. A Time Machine application located in the Applications folder. It is
         used to manage backups and to restore backups. Time Machine
         requires a backup drive that is at least twice the capacity of the
         drive being backed up.
    3. Time Machine requires a backup drive that is at least double the
         capacity of the drive(s) it backs up.
    Alternatively, get an external drive at least equal in size to the internal hard drive and make (and maintain) a bootable clone/backup. You can make a bootable clone using the Restore option of Disk Utility. You can also make and maintain clones with good backup software. My personal recommendations are (order is not significant):
      1. Carbon Copy Cloner
      2. Get Backup
      3. Deja Vu
      4. SuperDuper!
      5. Synk Pro
      6. Tri-Backup
    Visit The XLab FAQs and read the FAQ on backup and restore.  Also read How to Back Up and Restore Your Files. For help with using Time Machine visit Pondini's Time Machine FAQ for help with all things Time Machine.
    Although you can buy a complete external drive system, you can also put one together if you are so inclined.  It's relatively easy and only requires a Phillips head screwdriver (typically.)  You can purchase hard drives separately.  This gives you an opportunity to shop for the best prices on a hard drive of your choice.  Reliable brands include Seagate, Hitachi, Western Digital, Toshiba, and Fujitsu.  You can find reviews and benchmarks on many drives at Storage Review.
    Enclosures for FireWire and USB are readily available.  You can find only FireWire enclosures, only USB enclosures, and enclosures that feature multiple ports.  I would stress getting enclosures that use the Oxford chipsets especially for Firewire drives (911, 921, 922, for example.)  You can find enclosures at places such as;
      1. Cool Drives
      2. OWC
      3. WiebeTech
      4. Firewire Direct
      5. California Drives
      6. NewEgg
    All you need do is remove a case cover, mount the hard drive in the enclosure and connect the cables, then re-attach the case cover.  Usually the only tool required is a small or medium Phillips screwdriver.

  • Which is better, Kindle Plugin or Calibre?

    I am wanting to create a kindle friendly file of the book I am working on. I know that Amazon released a Kindle Plugin for ID but I have read that there are various issues that it has because it is free and a beta version. Anyway, for those of you who have converted epub to mobi (using Calibre) and the Kindle Plugin. Which is better?
    Thanks!

    Gpcn,
    I'm going to highly recommend the new Airport Extreme. I've been having all sorts of wifi and networking issues because of the saturated 2.4 GHz spectrum in my surrounding neighborhood.
    I finally bit the bullet on friday night and purchased the Airport Extreme. I could not be happier!
    I used to top out at around 8 Mbit/s download and 1 Mbit/s upload with my older Linksys setup. Now i'm getting 40+ Mbit/s and 2 Mbit/s respectively.
    Not only that, but i'm no longer dropping my wifi with my devices (latops, iPads, iPhone, etc). It's very consistent and the speeds are amazing!
    Sure it may be pricier than others, but it's worth every penny. The setup is very easy and you get Three Gigabit Ethernet LAN ports for connecting computers or network devices as well as built-in NAT support for security. You are better off getting the Airport Extreme.

Maybe you are looking for