2 connections, either one can throw an exception

In my application I have 2 connections open to the different DBs at the same time. Either operation ( select/update etc ) can throw an exception. I don't want to embrace every SQL statement with the different "try ... catch" block, because it will be too messy. Is there any way to determine what connection threw an exception.
Sample :
try{
Connection conn1 = ...
Connection conn2 = ...
PreparedStatement ps1 = conn1.getPreparedStatement(...);
PreparedStatement ps2 = conn2.getPreparedStatement(...);
ps1.executeQuery(qstring1);
ps2.executeQuery(qstring2);
catch ( SQLException ex){
// Can I put some logic here which will tell me whether the problem related to conn1 or conn2 ?
System.out.println("Exception : " + ex);
}

vs777 wrote:
I have a "global" DB instance where my metadata and instance-specific data resides ( domestice data ). I also have "secondary" DB instance with ( foreign data ) to which I might connect at the run-time if the application logic requires. I am updating metadata Sounds like you want to do "change data capture". If that's the case, I'd recommend looking into your database vendor's capabilities rather than doing this in Java. I'd also look into database links and triggers if your database supports them. Sounds like you're doing something that's best left to the database, not your application. It could be done behind the scenes. It sounds like more of a pure database play rather than business logic.
throughout the application "metadata"? What does that word mean to you? Please explain.
So you're changing the schema dynamically? Metadata means describing the tables and columns. That's changing as the app runs? Sounds confusing.
as well as retrieve and update data in one of the instances depending on conditions, so it's really inconvinient for me to wrap every SQL statement ( execute/select/delete method ) with "try ... catch" block.Inconvenient, but necessary. Somebody has to handle exceptions.
Sounds like you need to think about a way to not repeat code.
I have an application up-and-running for several months already and "2 DB instances" requirement came up just recently, so I am not planning to redesign an application but to handle SQL exceptions properly.So what do you want here? What are you asking if you're not willing to redesign anything?
You're probably not even aware of two phase commit. What happens to your app if the insert of the data succeeds but the metadata does not? Ooops, out of synch. Do you roll back manually? How does the app alert you to the need to do so?
%

Similar Messages

  • HT1212 The problem is that my iphone isnt connected/synced to iTunes and i've forgotten my password so iTunes isnt connected either so can someone pls help me?

    The problem is that my iphone isnt connected/synced to iTunes and i've forgotten my password so iTunes isnt connected either so can someone pls help me?
    PLEASE HELP ME

    Hi Someonewashere,
    In the article you were coming from, there is actually a section regarding what to do if you have never synced to iTunes before:
    If you have never synced your device with iTunes, or you do not have access to a computer
    If you see one of following alerts, you need to erase the device:
    "iTunes could not connect to the [device] because it is locked with a passcode. You must enter your passcode on the [device] before it can be used with iTunes."
    "You haven't chosen to have [device] trust this computer"
    If you have Find My iPhone enabled, you can use Remote Wipe to erase the contents of your device. If you have been using iCloud to back up, you may be able to restore the most recent backup to reset the passcode after the device has been erased.
    Alternatively, place the device in recovery mode and restore it to erase the device:
    Disconnect the USB cable from the device, but leave the other end of the cable connected to your computer's USB port.
    Turn off the device: Press and hold the Sleep/Wake button for a few seconds until the red slider appears, then slide the slider. Wait for the device to shut down.
    While pressing and holding the Home button, reconnect the USB cable to the device. The device should turn on.
    Continue holding the Home button until you see the Connect to iTunes screen.
    iTunes will alert you that it has detected a device in recovery mode. Click OK, and then restore the device.
    iOS: Forgotten passcode or device disabled after entering wrong passcode
    http://support.apple.com/kb/HT1212
    Regards,
    - Brenden

  • One method throw many exception

    7. Create three new types of exceptions. Write a class with a method that throws all three. In main( ), call the method but only use a single catch clause that will catch all three types of exceptions.
    Ok, I am learning java language from bruce eckel book. That is the exercise. I m having dificulties.
    How can one method throw more than one exception?
    class Satu extends Exception
       Satu() { }
    class Dua extends Exception
       Dua() { }
    class Tiga extends Exception
       Tiga() { }
    class ThisIsIt
       public void f() throws Satu, Dua, Tiga
          throw new Satu();
          throw new Dua();
          throw new Tiga();
    public class Enam
       public static void main( String[] args )
          try
          ThisIsIt a = new ThisIsIt();
          a.f();
          catch( Exception d )
          System.out.println( "Doing something here" );
    }That code won't even compile because :
    Enam.java:21: unreachable statement
    throw new Dua();
    ^
    Enam.java:22: unreachable statement
    throw new Tiga();
    Do I interpret that question wrong????

    The problem you have is that when the code comes to the first 'throw' command it will throw the exception and exit the method (like a return does) so the code after will never be reached. In order to test your code you need to put some 'if's around the throws or give it a parameter from the console. eg.class ThisIsIt
        public void f(int errorType) throws Satu, Dua, Tiga
            if (errorType ==1)
                throw new Satu();
            if (errorType ==1)
                throw new Tiga();
            if (errorType ==1)
                throw new Dua();
    }Ted.

  • I can not connect my ipad2 or my iphone 4s to itunes. when i connect either one it says "Can not connect beacause apple mobile device service has not started". PLEASE HELP!!!!

    I CAN NOT CONNECT MY IPAD 2 OR IPHONE 4S TO ITUNES TO SYNC. I WAS HAVING PROBLEMS WITH IT EARLIER AND FIXED THAT BUT NOW WHEN I CONNECT THEM BOTH THEY DO NOT CONNECT!!! CAN ANYONE PLEASE HELP!!

    There are instructions on this page for starting the AMDS, and how to set it to start automatically : http://support.apple.com/kb/TS1567
    For future info, typing in all capitals is considered SHOUTING

  • 2 routers - computers connected to one can't "see" computers on other

    Router1 is WRT54G 192.168.0.1 subnet 255.255.255.0 doing DHCP starting at 192.168.0.10. This is connected directly to my cable modem.
    Router2 is WRU54G-TM and ran through the default setup from TMO. Despite the urging of the setup, I didn't wan't to replace my WRT54G with the new one. So, it's set with IP of 192.168.24.1 subnet of 255.255.255.0 and is also doing DHCP starting at 192.168.24.100.
    Computers on both routers route fine to the internet. The problem is computers on Router1 can't be seen by computers on Router2.
    From Computer2 on Router2 I can ping Computer1 and (on Router1) get correct IP address (192.168.0.16) but get "Destination host is unreachable".
    I'm guessing this is a subnet mask issue? Or do I need to do something with routing tables? Or am just demonstrating my ignorance
    I appreciate any help.
    Solved!
    Go to Solution.

    digger69 wrote:
    From Computer2 on Router2 I can ping Computer1 and (on Router1) get correct IP address (192.168.0.16) but get "Destination host is unreachable".
    That sentence is fully unclear to me. Where is Computer 1? You first write you can ping computer1. Then you write you get an error. When do you get the error exactly? What do you get when you ping computer1? Which computer gets the "correct IP address 192.168.0.16"?
    Your problem is neither a subnet mask problem nor a routing table problem. You have internet from both routers. If there was a subnet mask or routing issue you would not have internet.

  • Can synchronized( someObj ) ever throw an exception?

    I know that object.wait() can throw an exception (IllegalMonitorStateException or InterruptedException) can synchronized ever do the same?
    For example:
    synchronized( obj ) //does this line ever throw an exception?
    }What is that synchronized line in byte code?

    [Section 14.19 of the Java Language Specification|http://java.sun.com/docs/books/jls/third_edition/html/statements.html#255769] says that if the value of obj is null, then a NullPointerException is thrown.

  • Constructor can throw exception or Not ?

    Anybody please tell me if the constructor throws an exception or not ?
    Please reply soon
    Thanks
    Amitindia

    A constructor can throw an Exception. However I
    would suggest throwing the generic Throwable, Error,
    Exception or RuntimeException rather than a specific
    exception is bad practice and you should choose an
    appropirate exception to throw.All depends on wich kind of exception you are throwing,checked or unchecked. It's an even worse form to throw a RE, Error, or Throwable when you are throwing in fact a checked exception.
    Nevertheless, I do agree, you must always strive to not throw exceptions, of any kind, in your construtor code. Construtors should be simple and reliable. Unles you have a very compelling reason to not do it, try to isolate the risky parts of the code where they are called ofter object construction or class loading.
    May the code be with you.

  • Can two different SRM clients systems connect to one R/3 Back-end system?

    Hello,
    Trying to developing SRM Co-Exist/Global strategy, based on the following scenario:
    1.  Two different SRM client systems, each at DIFFERENT SRM Version/Release Level.  SRM system "A" runs in Stand-Alone and Extend Classic Scenario mode.  SRM system "B" runs in Classic Scenario mode
    2.  Two different R/3 back-end systems, each with SAME R/3 4.7 Version/Release Level.
    Question 1:  Can the two (2) different SRM client systems be connected to one (1) of the R/3 back-end systems?
    Question 2:  Are there any Basis Plug-In (PI_BASIS) issues/difficulties to consider from either the SRM client or R/3 back-end side?
    Question 3:  Does each SRM client need it own unique transaction document type(s) and number range(s) definitions?
    Question 4:  Are there any other difficulties, for example, with RFC and Partner Profile related definitions and what are the steps to address/resolve difficulties?
    Please advise and thanks in advance for your feedback!
    Regards,
    Ed
    Edited by: Ed Shigo on Mar 16, 2009 6:40 AM

    Question 1: Can the two (2) different SRM client systems be connected to one (1) of the R/3 back-end systems?
    They can be connected
    Question 2: Are there any Basis Plug-In (PI_BASIS) issues/difficulties to consider from either the SRM client or R/3 back-end side?
    Make sure that you have unique consumer entries for Middleware for Material replication, RFCs etc
    Question 3: Does each SRM client need it own unique transaction document type(s) and number range(s) definitions?
    Yes you need to have them.
    Question 4: Are there any other difficulties, for example, with RFC and Partner Profile related definitions and what are the steps to address/resolve difficulties?
    Don't see any difficulties as long as the a structured approach is followed.

  • Two Macs - only one can connect to Airport at a time

    Starting today, after 10 days of successful operation, when I came home I couldn't connect to my home (new "square" Airport Extreme) network with my Core 2 MacBook Pro. My wife was happily connected on her PowerBook G4.
    Puzzled, I tried a few obvious things:
    Airport OFF, Airport ON ... no joy
    Logout and back in ... no joy
    Restart ... no joy
    Then I turned my attention to the Base Station:
    Restart ... nope
    Change to "None" security ... nope
    Change back to "WPA Personal" ... nope
    Humbled, I stopped and had dinner. My wife's G4 went to sleep, my Intel went to sleep. Now it gets interersting! My Intel woke up first and immediately joined the network -- I'm happy till I hear my wife say SHE can't get connected.
    To make a long story short, I have two laptops on my desk, and only one can connect at a time! This is BIZARRE. Turn off Airport on either one and its buddy gets a connection immediately, and vice versa. Sleep the connected one and the other connects.
    I am out of ideas.
    Errors on the G4:
    Feb 28 20:09:45 localhost configd[35]: WirelessConfigure: 88001003
    Errors on the MBPro:
    various 88001006 errors as reported by others in this forum.
    Both Machines at all the latest updates; the MBPro has the new Extreme software installed from the CD that came with the new hardware.
    I would welcome suggestions ...
    MacBook Pro Core 2   Mac OS X (10.4.8)  
    G4 Cube   Mac OS X (10.4)  

    Software Update is not offering me any Airport updates on the G4 (or the Intel).
    The recent Airport Update, "AirPort Extreme Update 2007-001", is of course only for Intel Macs.
    They could only be "trying to use the same IP address" if they were not configured to use DHCP, but they are configured to use DHCP, and whichever connects does get an address in the 10.0.1.[2-200] range so I think that's not the problem.

  • B1DiEventService:  ERROR :Connect throw an exception: Host is unknown

    Hi,
    I tried to create an event service. I followed the example of VB code. When I try to connect to the service using following code:
    Function Connect() As Boolean
            Try
                ' Create an instance of B1DIEventsService, Company object as parameter
                evtService = New B1DIEventsService.B1DIEventsService(oCompany)
                'Connect to the service
                evtService.Connect(New B1DIEventsService.B1DIEventsConnectionLostDelegate(AddressOf OnServerShutdown))
                Return True
            Catch ex As B1DIEventsService.B1DIEventsException
                SBO_Application.MessageBox("EVENT_ERROR :" + ex.Message)
            Catch ex As Exception
                SBO_Application.MessageBox("ALG_ERROR :" + ex.Message)
            End Try
            Return False
        End Function
    I get the message EVENT_ERROR :Connect throw an exception. Host is unknown
    I'm using the examples for 2005 SP01 private connections.
    Logfile shows following info:
    TIME;LEVEL;INFO;
    31-5-2007 15:22:26;INFOPLUS;TraceLevel: Warning
    31-5-2007 15:22:26;INFOPLUS;PortNumber: 4334
    31-5-2007 15:22:26;INFOPLUS;KeepAlivePeriod: 2000000
    31-5-2007 15:22:26;INFOPLUS;KeepAliveMax: 12000000
    31-5-2007 15:22:26;INFOPLUS;MaxSizeAction: Replace
    31-5-2007 15:22:26;INFOPLUS;MaxFileSize: 6000000
    31-5-2007 15:22:28;INFOPLUS;Connect to server.
    31-5-2007 15:22:29;INFOPLUS;Client: Reference to server acquired
    31-5-2007 15:22:34;ERROR;Connect throw an exception: <u>Host is onbekend</u>
    The last part (underlined) is dutch and means "Host is unknown."
    Can anyone help please?
    Thanks and Regards,
    Sander

    Hi Sander,
    It seems like the name or adress of the server is unknown for the machine, it cannot connect to it or the server is not running.
    Is your oCompany object initialized and connected to the DI API before creating the B1DIEventsService?
    Have you tried to run client and server side in the same machine to do a small test?
    The problem is at the .NET Remoting interface, it cannot connect to it.
    Regards
    Trinidad.

  • I bought a mini DVI to HDMI convertor and  a HDMI to VGA cable to connect my mac book pro to a tv but it doesn't work any one can help.\\\\\

    i bought a mini DVI to HDMI convertor and  a HDMI to VGA cable to connect my mac book pro to a tv but it doesn't work any one can help.

    I would suggest looking into a Thunderbolt to HDMI connector. In this case, you may be able to use the TV as an external monitor. For this option, please confirm through additional research. I have not tested it personally.
    You can also use an Apple TV, which connects with HDMI. In this case, you can use Airplay Mirroring. Not all Macs support Airplay Mirroring, so you need to check first. I have a Mid-2011 27" iMac, and it supports Airplay Mirroring. I don't use it often because my TV is in another room, but I just tried it and it worked. It had to change the screen resolution to work well, so I don't know if I would want to use it as my day to day monitor. http://support.apple.com/kb/ht5404

  • HT1369 hey, when I connect either my ipod or ipad to itunes I get the promt ' i tunes was unable to load data class information from sync services. Reconnect or try again later'. Can anyone help me with syncing my devices?? Thanks in advance

    Hey, when I connect either my ipod or ipad to itunes I get the prompt 'itunes was unable to load data class information from sync services. Reconnect or try again later. Can anyone help me with syncing my devices?? Thanks in advance

    I am having the same issue, anyone else ?

  • Can I transfer data from my G4 to my IMac over a firewire without them syncing or messing either one up - do not want to modify either one...!

    Can I transfer data from my G4 to my IMac over a firewire without them syncing or messing either one up - do not want to modify either one...!

    Boot the G4 Mac into Target mode...
    http://support.apple.com/kb/HT1661
    That should make the G4 look like a big FW drive to the iMac.

  • I don't have very much space left on my iCloud backup. I had a previous iPhone, my current iPhone and my iPad that are all connected to one cloud. Can I delete the backup from my previous iPhone? Will it delete in the cloud AND on the phone?

    I had a previous iPhone, my current iPhone and my iPad that are all connected to one cloud. Can I delete the backup from my previous iPhone? Will it delete in the cloud AND on the phone? or does it just delete from iCloud? or does it just delete from the phone? Someone please help!

    You can delete the backup without any problem. Only the backup will be deleted from iCloud and nothing else will be deleted, so you can do it without worrying about losing data on iCloud or your devices

  • My macbook air will not connect to the internet due to a self assigned IP address. I have tried trawling the support forums, but either I can't understand the suggestions, or they don't work. Please explain to me in simplest terms how to fix this. Thanks!

    My macbook air will not connect to the internet due to a self assigned IP address. I have tried trawling the support forums for hours, but either I can't understand the suggestions, or they don't work. Please explain to me in simplest terms how I can fix this. Many thanks!

    The warranty entitles you to complimentary phone support for the first 90 days of ownership.
    If you bought the product in the U.S. directly from Apple (not from a reseller), you have 14 days from the date of delivery in which to exchange or return it for a refund. In other countries, the return policy may be different. If you bought from a reseller, its return policy applies.

Maybe you are looking for

  • Wish list entry for CASE designers/manufacturers

    I want a clear plexi sturdy case (like the xtrememac cases for iPods) that I don't have to remove to be able to put my iPhone into the dock. Come on folks, it can be done. It is possible to design something like that. All the nice plexi cases on the

  • How to purchase mountain lion

    Been trying to upgrade now for an hour and it wont let me just keeps taking me back to preview page when i want to buy it. I just want to use my new iphone 5

  • Avoid positive commissions for a bilateral facility

    Dear gurus: I'm new in FSCM world and I am facing the following problem: In a bilateral facility product (obtained) I've defined a charge for the "amount utilized". It doesn't work when the company makes a transfer bigger than the amount utilized to

  • Can I import Outlook notes to iPhone

    How can I import Notes from Microsoft Outlook 2007 into iPhone?

  • Mountain lion microphon intern doesn't go

    Imac 2007 - it is impossible to activiate the internel microphon under mountain lion - siri doesn't work