Can you have two connections to database

I am running two java programs which access the same database. One runs forever, and keeps the same connection up. The other program, lets say does a simple update, but it stalls and will never do the update. If I kill the first programs connection, then the second program can do the update. I am using the jdbc thin client. Is there a way I can have these both run and not stall?

The short answer is, yes.
There are two general approaches to the problem. The first approach is to use various locking, commit and rollback techniques. The basic premise is that if program A runs into a problem, the database drops A and reverts back to the previous state before responding to program B. This is highly dependent upon the database you're actually using, and probably beyond the scope of this forum.
The second approach is to code your programs with a philosophy of "get in, do it, get out" as quickly as possible. In other words, do NOT leave a database connection open if you can avoid it.
Essentially your program makes a connection, does a select query, copies the results into a data structure you define, and exits. Then you're free to play with the results as you see fit. When the time comes to do an update, you make the connection, perform the update, then immediately exit. If you need to test it, make another connection, do a select on that record, copy it, close the connection, then compare the copy with what you anticipate.
There is the added benefit that whenever you close the connection, most databases will then do whatever commits need to be done, and release any deadlocks that may be in place.
Your problem isn't really that your database cannot do two connections - its the fact that your database does not want to let two separate people make changes to the same table at the same time. There's an obvious reason for it and we can go into more detail if you want.
But essentially, if you do each transaction as quickly as possible, and let the database clean up after each transaction, you will avoid most, if not all of the problems you're experiencing.
Don't worry about the overhead of creating and closing connections. If it does become a problem, you can always use a "Connection Pool" (search for it on the forums if you want to know more). You just don't want to be in a position where the database is saying "I can't give you the info you want because I don't know if this other program is going to change any of it before giving control back to me."

Similar Messages

  • Can you have two Apple IDs on one IPAD? One for school and one for home?

    Can you have two Apple IDs on one IPAD? One for school and one for home?
    If so do you know how to do it?

    It depends on what you want to do.
    You could, for example, have one AppleID for iCloud backup [and therefore message syncing, notes syncing, etc] and a second one for iTunes [music, iBooks, etc].
    But if you are looking for a way to flip everything between different appleIDs, then no.

  • Can you have two apple ids on one mac?

    Can you have two apple ids on one mac? We each have iPhones and want to utilize iCloud.  Is this possible?

    No, in this case the 2 user accounts with its own Apple IDs would be completely seperated.
    If you want to share this things like music and app purchases you will have to to something else.
    1. Create two user accounts on your Mac (user A and user B).
    2. Create two iCloud accounts just for Mail, Contacts, Calendars, Photos, etc. (one for user A and one for user B):
    On your Mac (with Mac OS X Lion or Mountan Lion):
    Settings > Mail, Contacts, Calendars > iCloud > Create an Apple ID (button in left corner)
    On your iPhone, iPad or iPod touch (iOS 5 or later):
    Settings > Mail, Contacts, Calendars > Add Account > iCloud > Get a free @me.com address and create a new Apple ID
    3. It is not recommended because you shouldn't share your Apple ID account information with other people but you could set up your old Apple ID as an account just for store purchases (Apps, Music, ...) so that everyone of you can manage the purchases in their own library (Access is limited to 10 devices). Therefore you have to setup this "old" ID in Settings of your iOS devices (Settings > iTunes & App Store) and in iTunes on your Mac.

  • Can you have two different users with itune accounts on the same computer?

    Can you have two different users with separate itune accounts on the same Ipad?

    Yes, create another user profile on the computer and each user can log into their own profile that way.

  • Can you have two itunes accounts on the same computer?

    Can you have two itunes accounts on the same computer and if so how do you access them without syncing each others music?

    Yes. Use separate iTunes libraries(launch iTunes with the Shift(Windows) or Option(Mac OS X) key held down as needed), or different user accounts on the computer.
    (100648)

  • Can you have two apple id accounts on one computer??

    Hi all
    Can you have two seperate apple ID accounts on the one computer?? Imessaging wont work between two iphones if both iphones (husband & wife) use same apple ID account. any help appreciated

    Yes, you can. Apple IDs are really not meant to be shared.

  • CAN YOU HAVE TWO I TUNES ACCOUNT ON ONE COMPUTER?

    CAN YOU HAVE TWO I TUNES ACCOUNT ON ONE COMPUTER?

    The problem with making separate accounts is that this is a laptop, so likely not a huge hard drive, and if the three iTunes libraries need to have a lot of the same music (because everyone or two or three like some of the same stuff) you end up with double or triplicate copies of the music on the hard drive eating up drive space. Since they don't use his laptop normally, creating more accounts (with all the associated files and drive space usage each account would eat up) it probably isn't worth it.
    Instead, the best approach is like Chris said, to make playlists for the girls in the main library and then set up the various iPod to either sync everything (if big enough) or sync only specific playlists (if not big enough).
    Alternatively, they can set their iPods to manual syncing and then when Dad is visiting they can hook up their iPods and "shop" the library and drag in whatever they want to add to the iPods and delete what they no longer want.
    Patrick

  • Can you have two iCloud accounts for one Apple id?

    Can you have two iCloud accounts for one Apple id?

    the appleID is you in the ios world if you have an iphone and an ipad and an Ipod touch and an appletv and a mac then you should use 1 appleID on all of them it does not mean the same data is on all of them unless you want it to be

  • Can you have two Enterprise CA on the same AD Domain at the same time

    Hello
    Can someone please help me with the following question
    If I have a Windows 2003 R2 Enterprise Root CA on the AD Domain can I also Add a separate Windows 2012 R2 Enterprise Root CA to the same domain.
    We do not use Autoenrollment on the existing 2003 R2 CA.
    Network guys want to introduce a Cisco BYOD (Bring Your Own Devise) solution using Cisco ISE (Identity Services Engine) which uses SCEP/NDES and therefore need certificates from CA. The thing is the ISE recommend 2008 AD CS as a minimum
    Therefore I wonder if Installing a 2012 R2 Root CA that only provides certificates via the NDES/ISE solution would be a possibility. 
    I understand the Root CA Cert is held in a container under the 'Configuration' partition in Active Directory. Therefore can you have Two Root CA certs in the AD container at the same time for the same AD Domain/Forest?
    The idea would then be to migrate other services to the new CA and phase out the old 2003 R2 CA over time.
    Thanks All
    AAnotherUser__
    AAnotherUser__

    On Thu, 18 Sep 2014 09:18:43 +0000, AAnotherUser wrote:
    Therefore can you have Two Root CA certs in the AD container at the same time for the same AD Domain/Forest?
    Yes.
    Paul Adare - FIM CM MVP
    You are trapped in a maze of screens and ssh sessions all alike.
    It is dark, and you are likely to log off the wrong account. -- Nep

  • Can you have two slides shows on the one interactive page?

    I'm just new at learning interactive pdfs in indesign so sorry if this is common knowledge. I know how to create a slide show on a page, but can you have two slide shows on the one page or more for that matter? (Ideally I need 3.) Each slide show has its own set of images and buttons.

    Just :http://www.youtube.com/watch?v=Dm0aeMUPZ4U
    But I'm happy to create them a different way if needed be.

  • Can you have two apple ID's and iTunes accounts on 1 home computer?

    Can you have two apple ID's and iTunes accounts on 1 home computer?

    Yes. Use separate user accounts on the computer.
    (94753)

  • Can you have two seperate acounts on one MAC and if so how do you do it?

    Can you have two seperate acounts on one MAC and if so how do you do it?

    Look at Method One in this document:  How to use multiple iPods, iPads, or iPhones with one computer, http://support.apple.com/kb/HT1495

  • Can you have two nicknames for game center for two kids linked to one Apple ID?

    Can you have two nicknames in game center (for each child) linked to one email/apple ID?

    On each of the phones you're gonna use a new Apple ID for iCloud: turn off Contacts, Calendars, etc. for iCloud. You'll be prompted to keep the data or delete it from the phone, then turn off iMessage, FaceTime & delete the iCloud account...Settings>iCloud...scroll down...delete account. Then, setup iCloud using the new Apple ID, turn on iMessage & Facetime.
    This will have no affect on the ID you share for iTunes content, & you can continue to do so.

  • My husband does not have an itunes account and wants to set one up and we only have the one computer. can you have two separate accounts? We want to set up separate iphones.

    My husband does not have an itunes account and wants to set one up and we only have the one computer. can you have two separate accounts? We want to set up separate iphones.

    How to use multiple iPods, iPads, or iPhones with one computer

  • HT204053 can you have two separate iCloud accounts on one iMac device?

    can you have two separate iCloud accounts on one iMac device?

    You can have only one iCloud "user configuration" per local user on the Mac. Who the local user belongs to doesn't mind. Since it's a local user it's not related with who actually uses it. So let's say you want to set up Photo streaming using your iCloud user, just configure iCloud (under System Preferences) the same way you did on your phone and you're done.
    But, beware: if you're only interested in synching photos, uncheck everything else when configuring iCloud on the Mac, otherwise you will merge, for example, your husband contacts, calendar and mail with those on your phone.
    If you want to avoid any problems you can easily create another local user on the Mac with your name, under System Preferences, System, Users & Groups. After you create the user, logoff. The Mac will ask if you want to disable autologin (since there's more than one user that can log in now), answer yes and you will be presented with a logon screen. Click on your account name, insert the password and configure iCloud to sync with your phone.

Maybe you are looking for

  • How to access answer in crowdsupport

    dont know how to access mail in crowd support

  • ICloud crashing system preferences

    Installed the 10.7.2 update this morning on both my iMac (Mid 2007) and MacBook (Late 2008) and everytime I try to open the iCloud preference pane it crashes. Activity monitor shows system prefrences is using loads of CPU and memory resources and the

  • Consolidating all iPhoto files/images in one place

    OK: Excuse me if this is a boring or redundant question, but here it is - I am using the latest version of iPhoto on MBP, and I have some earlier versions on iPhoto on a Quicksilver in several places. I would like to have everything in one place, if

  • A/V controls disabled QT

    I recently tried to view the iPhone keynote address. However, no sound but video was fine. When opening A/V controls, I can adjust hue and brightness, but the audio sliders are "gray" and disabled. volume is completly down but I cannot adjust.

  • Error on a put call

    I am using a CDS database, sometimes I get an error on a put call - ENOENT i.e, No such file or directory This is not one of the documented return codes for a put. Under what scenarios can we get these errors ? The file ofcourse is still there. Any h