How does JAVA catch Trigger's Exception?

I have a JAVA program which call a SQL (insert a record into table A). On the other hand, I have a trigger written in Oracle DB, which inserts a record to table B after a record has been added to table A.
Now, I find that when the trigger fails, both table A and table B doesn't have the new record. It seems to rollback the insertion into table A.
I want to catch the exception in the JAVA, but no exception is returned to the JAVA code. However, when i simulate the insert statement in the Oracle DB, there is some exception returned.
Do anyone know how to get the exception in JAVA?
--- java code reference ---
try
xxx.executeUpdate("insert into xxx (....) values ('"...."');
}catch(Exception e)
e.printStackTrace();

Further information of the scripts
------------------- Script in Oracle ----------
create table a
(a1 varchar2(10));
create table b
(b1 varchar2(10));
create table c
(c1 varchar2(10));
create table d
(d1 varchar2(10));
insert into b values ('1');
insert into b values ('2');
insert into b values ('3');
insert into b values ('4');
insert into c values ('1');
insert into c values ('2');
insert into c values ('3');
CREATE OR REPLACE TRIGGER abc
AFTER INSERT ON a
FOR EACH ROW
DECLARE
     temp_b1 varchar2(10);
BEGIN
     SELECT b.b1 INTO temp_b1
     FROM b, c
     WHERE b.b1 = c.c1
     and b.b1 = :New.a1;
     INSERT INTO d(d1) VALUES(temp_b1);
END;
---------------- Run in SQLPLUS --------
SQL> insert into a values ('4');
insert into a values ('4')
ERROR at line 1:
ORA-01403: no data found
ORA-06512: at "BCA.ABC", line 6
ORA-04088: error during execution of trigger 'BCA.ABC'
---------------- Script in JAVA ----------
import java.io.*;
import java.sql.*;
import java.util.*;
import oracle.jdbc.OracleDriver;
import oracle.jdbc.driver.OracleSQLException;
public class langtest
     public static void main(String args[])
          throws Exception
          DriverManager.registerDriver(new OracleDriver());
          Connection connection = DriverManager.getConnection("jdbc:oracle:thin:[user_name]/[password]@[ip_address]:[port]:[service]");
          PreparedStatement pst = connection.prepareStatement("insert into a values ('4')");
          try {
               pst.execute();
          } catch (OracleSQLException e)
               System.out.println(e.getMessage());
               System.out.println("done");
---------------- Run in JAVA Program -----
There is no error message in JAVA. No exception prompt out. Do you know how I can get the exception in JAVA, just like the Oracle SQLPLUS encountered?
Kelvin

Similar Messages

  • How does java support the concept of destructor?

    How does java support the concept of destructor?

    @KunalSurana: before you flood the forum with basic questions, do us a favour and read.
    [Sun's basic Java tutorial|http://java.sun.com/docs/books/tutorial/]
    [Sun's New To Java Center|http://java.sun.com/learning/new2java/index.html]
    Includes an overview of what Java is, instructions for setting up Java, an intro to programming (that includes links to the above tutorial or to parts of it), quizzes, a list of resources, and info on certification and courses.
    jGuru
    A general Java resource site. Includes FAQs, forums, courses, more.
    JavaRanch
    To quote the tagline on their homepage: "a friendly place for Java greenhorns." FAQs, forums (moderated, I believe), sample code, all kinds of goodies for newbies. From what I've heard, they live up to the "friendly" claim.
    [Yawmarks List|http://forums.devshed.com/java-help-9/resources-for-learning-java-249225.html]
    [The Java Developers Almanac|http://www.amazon.com/exec/obidos/tg/detail/-/0201752808?v=glance]
    [http://javaalmanac.com|http://javaalmanac.com]
    Bruce Eckel's [Thinking in Java(Available online.)|http://mindview.net/Books/DownloadSites]
    Joshua Bloch's [Effective Java|http://www.amazon.co.uk/exec/obidos/Author=Bloch,%20Josh]
    Bert Bates and Kathy Sierra's [Head First Java|http://www.amazon.com/exec/obidos/tg/detail/-/0596004656?v=glance ]
    James Gosling's [The Java Programming Language|http://www.bookpool.com/sm/0321349806]
    Gosling is the creator of Java. It doesn't get much more authoritative than this.
    Joshua Bloch and Neal Gafter [Java Puzzlers.|http://www.javapuzzlers.com/]

  • How does java implements runtime polymorphism.?

    Hi all.
    we know how does runtime polymorphism take place in java.
    But my quesions is , how does java implement it internally.
    in C++, with the use of keyword virtual , complier decides to make a call at runtime using virtual table and Vptr.
    like in c++,
    class base {
    public:
    virtual void show(){
    cout<<"I am in base class"<<endl;
    class child : public base {
    public:
    void show(){
    cout<<" I am in child class"<<endl;
    int main(){
    base*p = new child();
    p->show();
    return 0;
    out put - I am in child class.
    but if we remove the virtual keyword then output
    I am in base class..
    We know how it happens
    but in java
    class base {
    void show(){
    System.out.println("I am in base class");
    class child extends base {
    void show(){
    System.out.println(" I am in child class");
    class demo {
    public static void main(string args[ ]){
    base b;
    child c = new child();
    b = c;
    b.show();
    output is - I am in child class
    but how can i bring the output as
    I am in base class ---
    complier knows that b is base reference so y doesnt it just use base version.

    if all methods are virtual..then we should always have runtime binding but we do have early biding too.
    shouldnt we able to call base verison using a base reference variable like in c++.
    May be I m mixing big times java n c++. But it seems to me as core java is much like c++ . The things u can do in c++ , u can do same in java in different ways.

  • How does the WF trigger for a PO

    Hi!
    The buyer creates a PO in ME21N, and completes release 00. Release 01 happens through workflow for PO release.
    My question is, once the buyer completes 00 release, how does the Workflow trigger? Is there any event that triggers the PO release WF? If yes then where can I see this information?
    Thanks,
    Anwar.

    go into SPRO
    Materials Management|Purchasing|Purchase Order|Release Procedure for Purchase Orders|Define Release Procedure for Purchase Orders
    <b>Release Groups
    <i><b>Release Codes
    </b></i> this one decide if you should trigger the workflow or not.
    Release indicator
    <i>Release Strategies</i>
    Here you setup how the release should work </b>
    Workflow
    When this is done the following template should start. WS20000075
    Hope this helps
    best regards erik

  • How does java.exe behave if I only use -Xmsn option?

    Hi,
    if I only set the -Xmsn option and do not set -Xmxn option when I launch my Java application, how does java.exe behave? Does the heap will automatically grow like what Bea's JRockit does when my application requires more memory?
    I use JDK 5.0.
    Thanks for your help!

    If your application needs the space, the JVM will grow the heap up to the
    default value of -Xmx. Note that it will run a garbage collection cycle before
    expanding the heap, and it may take a few or several cycles to expand to
    the -Xmx value. How fast or slow it expands depends somewhat on the
    behavior of your application (how much it allocates and how long the
    objects live).
    The default value of -Xmx depends on the platform; see
    http://java.sun.com/docs/hotspot/gc5.0/ergo5.html.

  • Java Gurus: How does Java compare to 4GLs?

    I've been using Java for a year now. I love Java. As a 3GL, how does Java compare to a 4GL?
    (I can't say I know a whole lot about fourth generation languages. The only 4GL that I'm a little familiar with is Clarion.)
    What are your thoughts?

    What is 3GLs and 4GLs? You mean Programming Language and Scripting Language?

  • How does Java file I/O move files?

    I'm working support for an integration platform, and there's a problem at a customer that seems to crop up once in a blue moon, yet still all to often. Its a bit difficult to track down, because they are using an old piece of software that is not officially supported anymore, but the problem still needs to be solved and I could use some help to either confirm or dismiss my suspicion of what might be the cause of it.
    What happens is this....
    Their system places a file in a folder, and the file is /supposedly/ fully created, and then just moved to the folder. Then an adapter program takes the file, puts it on a messaging queue, and after that is successful, it moves the file into a backup directory.
    Now, what has happened is that sometimes, the files that end up being sent are incomplete. Either the writing application messed up, or the adapter somehow went crazy. But more puzzling is that I've observed that the files have been correctly sent, but the file that ended up in the backup-directory was empty. It is not possible to send an empty file through the platform, since there's transformation logic that handles it. Those parts I completely trust, but I need to verify if it might indeed be the adapter, or the customer's own systems that messes up the message.
    So the question really boils down to, how does the java file-I/O method for moving a file work? Does it copy it bitwise, or does it call the system's move-command? Because if it copies it bitwise, it might mean it reads the data at the exact moment the file is created but not yet filled, and then doesn't check again as it writes it to the storage, and then just deletes the file. If it calls the system's move command, the system wouldn't be able to move a file that is being written, and something else is more likely the problem.
    The machine is a windows 2000 server, sp4, and the java being used is jdk1.3.1_03.
    Rewriting the adapter is not an option, and it will hopefully be replaced in the near future (as in, within a year...) whenever the customer deems it can budget for the work. The adapter is not officially supported by us, but the platform is, and I need to pin-point the problem.

    So the question really boils down to, how does the
    java file-I/O method for moving a file work? Does it
    copy it bitwise, or does it call the system's
    move-command? It could be either one. Both are available, so it depends what the programmer for that tool decided to use.
    Without more details, it's impossible to be sure what the probem is, but a couple of general possibilities that fit what you've described pop to mind:
    * The copy/move/send step is happening before the file being written is flushed or closed. This might be because an exception in the writing code is causing the flush/close to be skipped entirely.
    * The copy/move/send is being called too soon.
    * The step that's reading the file after its been copied/moved/sent is ocurring before the file is completely there.

  • What is the output of Maya and how does Java use it in animation.

    What type of software is used and what input and output files are created in the animation process?
    From what I read:
    Maya is used to create polygon structures, perform rigging, and it attaches surface textures which are made in Photoshop. Then Maya creates key images or positions of the animation. Next Maya exports an image and a data file to do the neccessary transformations. Finally, Java uses the image and the data file to paint the images and their position based on the game logic's use of the data file.
    What have I missed or described wrong?
    I also need more clarity on the input files to Java and how Java stores and uses these files. The use of Maya images and files seems different. Is Maya or Java doing the transformations or are they both doing them? How does this work?
    Thanks for your help
    Jon

    Thanks for the explanations. What this means in my situation is that tags are an unnecessary way of spending a lot of time making my file system more complicated, without adding any value whatsoever. Without tags, I can find any of my 3,000 files with a few clicks. (On my computer, Spotlight has cobwebs. I very rarely need it, but it's wonderful when I do.) Now that I know how tags work, I can ignore it.
    A human being can only perceive a quantity of seven without counting or grouping; hence we arrange things in structures to keep the number of entitites low on each level. You don't need to count three objects to know that they are all there, but you do need to count twelve objects. Which is why Home Alone was believable. We sort screws and nails in jars and toolboxes have compartments. Even the grocery store has a hierarchical arrangement. You don't find steaks in the bakery section, or breakfast cereal in the produce department.
    Some people aren't organized, and that's not a bad thing, but no folder, no tag, and no group is going to change a fundamental personality characteristic.
    Thanks everyone for showing me that in my case, there's no point to tags. That saves me a lot of time.

  • How does java basically work?

    I know that java makes use of many classes which have inherent methods that do our work. But I want to know how those methods work. where are the files for its running? Like in println, how does it output to the console?
    please explain.
    And also tell me how java was built...
    Thanks in advance.
    Megamatrix.

    If you want to see the source code of the standard API classes it's very easy - during the installation of the jdk you can choose to install it. In that case there will be a large file called src.jar in the JDK installation directory. You can extract the sources from it with eg. winzip or the "jar" command line tool.
    And if you are interested in the source of the JDK itself, it can be downloaded too... http://www.sun.com/software/java2/index.html

  • How does Java Compiler deal with circular dependence?

    A simple example is in the most basic class Object, you have a toString() method which uses String class, but, a String is an Object class first. So when the compiler encounters this circular dependence situation, how does it deal with it?
    Anyone has some ideas?

    I studied this a while ago... I think I know the answer, but you can still confirm it.
    Suppose you said javac Object.java, the first thing it would do is load the file into memory and layout its functions. Then it will search for dependencies. Finding String on in the classpath, it loads that up into memory too. It then searches for String's dependencies and so on...

  • How does TPS34 get trigger in ECC?

    I am curious how does the table TPS34 get triggered when I am trying to replicate material to crm?   Does it get trigger in the code or is it through config when i put the name of my Function module it?

    It gets triggered via SAP function module PC_FUNCTION_FIND. Please do a where-used-list of this function module and you can also set specific break-points within these programs.

  • How does one catch WebUtil exceptions?

    We are automating Microsoft Word using the CLIENT_OLE2 built-in. In some cases, our requirements demand that Word be running in a visible window. One of our processes automates the same Word session repeatedly -- when a user unwittingly closes Word, and our process attempts to further automate the now-closed Word session, exception WUO-714 is raised, and an alert is displayed.
    The WebUtil documentation indicates that logging can be configured silently log exceptions without an alert being displayed, but I cannot find a way to actually catch them. Our process could recover gracefully from the scenario described above by simply relaunching Word -- if only we could catch the exception!
    Has anyone else already figured out to accomplish this?
    Thanks,
    Eric Adamson
    State of Michigan

    Herzliche Begrüßen Gerd,
    Thanks for your reply -- the error occurs in a PL/SQL block. Since my initial post, I have discovered that my test code contained a WHEN OTHERS THEN NULL statement. (When coding blocks, I often complete them with NULL statements, as I compile very often, to simplify tracking down errors. This strategy works wonderfully, when I remain focused, but the distractions of researching WebUtil errors evidently led me to overlook my mistake. Perhaps others may learn from my embarrassing lesson.)
    In any case, I am now able to catch the exception, and to handle it appropriately. Most importantly, readers should note that it was necessary to change the WebUtilErrorMode entry in FORMSWEB.CFG. By default WebUtilErrorMode=Alert -- this causes the error alerts to pop up, regardless of whether/not the exception ultimately gets handled. I have set WebUtilErrorMode=Console.
    Thanks for reading, and congratulations on winning the match with Costa Rica!
    Regards,
    Eric Adamson
    Lansing, Michigan

  • How does Java structure memory for an object's members?

    I'm trying to figure out how Java structures/allocates memory for objects. (Yes this is implementation specific. I'm using the Oracle 1.7 runtime for this.) I did some work on this here and here and the results are confusing.
    First off, in both referenced links, when I allocated an array of objects, the equivalent of new Object[10000], it used 4 bytes per object. On a 32-bit system this makes perfect sense. But I'm on a 64-bit system so what's going on here?
    Is Java limited to a 32-bit address space even on 64-bit systems?
    Is Java limited to a 32-bit address space per array and each array object then has a pointer to where the elements are?
    Something else?
    Second, I compared the memory footprint of 8 booleans vs. a byte as the variables in a class. The 8 booleans requires 24 bytes/object or 3 bytes/boolean. The single byte approach requires 10 bytes/object.
    What is going on with 3 bytes/boolean? I would understand 4 (making each an int) and definitely 1 (making each a byte. But 3?
    And what's with expanding a byte to 10 bytes? I would understand 8 where it's expanding a byte to a native int (I'm on a 64-bit system). But what's with the other 2 bytes?
    And in the case of different ways to create a RGB class it gets really weird.
    For a class composed of 3 byte variables it uses 24 bytes/instance. Expensive but understandable as each uses an int.
    So I tried where each class is a single int with the RGB stored in parts of the int (using bit shifting). And it's still 24 bytes/instance. Why on earth is Java taking 3 ints for storage? This makes no sense.
    But the weirdest case is where the class has a single variable of "byte[] color = new byte3;" Note that the byte is allocated so it's not just a null pointer. This approach takes less memory than the other two approaches. How???
    Any guidance as to what is going on here is appreciated. I have a couple of classes that get allocated a lot and the flywheel pattern won't work (these objects have their values changed all over the place).
    And an associated question, does the order of declaring variables matter? Back in the old days when I did C++ programming, declaring "int, byte, int, byte" used 4 int's work of space while "int, int, byte, byte" used 3.
    thanks - dave

    This is a quadruple crosspost.

  • How does Java store floating point numbers?

    Hello
    I'm writing a paper about floating point numbers in which I compare an IEEE-754 compatible language [c] with Java. I read that Java can do a conversion decimal->binary->decimal and retain the same value whereas c can't. I found several documents discussing the pros and cons of that but I can't find any information about how it is implemented.
    I hope someone can explain it to me, or post a link to a site explaining it.
    Cheers
    Huttu

    So it is a myth.
    I still ask because I observed a oddity: When I store 1.4 in c and printf( %2.20f\n",a); it I get 1.39999999999999991118. If I do the same in Java with System.out.printf( %2.20f\n",a); I get 1.4. If I multiply the variable with itself I get 1.95999999999999970000:
    double a=1.4;
    a=a*a;
    System.out.printf( %2.20f\n",a);
    {code}
    Does this happen because of the rounding in Java?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • How does java support the doc files

    Hai all,
    I am doing a project where the back up word files are to be displayed on the browser . If it is a text file we can give it as a input stream and if it is a image , it will take it as a .jpg . Then how the .doc can be inputed(I want the MS-word files to be inputed) .
    If u have a solution please mail it to
    E-mail ID : [email protected]

    I am bit confused about ur requirement.
    U cannot open a file thr' ur applet which runs in a browser. Do do so, u may have to modify the java policy file or use signed applet. These two links may be of some help for u.
    http://developer.java.sun.com/developer/onlineTraining/Programming/BasicJava1/data.html#applet
    http://java.sun.com/docs/books/tutorial/security1.2/tour1/step2.html
    But I have written a mail long back to ur email with regard to Java Securiy. plz read it. If u need more abt it, get back to me.

Maybe you are looking for

  • Parameter is Incorrect

    Hi, I am using a ATI TV Wonder 650 PCI for capturing live TV content to stream using FME 2.5. I am able to stream the video, but there is no Audio. when I choose ATI AVStream Analog Audio Capture, it does not seem to populate the sample rate and henc

  • Sync Exchange & MobileMe Calendars

    A user named Bob utilizes iCal with a MobileMe calendar. That calendar needs to sync to his Exchange calendar that is also setup in iCal, so other users can view Bob's calendar from within Outlook 2011. How can this be accomplished? Thanks.

  • How to set defalut value to DB current date time in EO using sql

    HI, I am using below query to set default date time as DB current date select to_char(sysdate, 'DD-MM-YYYY HH24:MI:SS') from dual but it is throwing exception (oracle.jbo.AttributeLoadException) JBO-27021: Failed to load custom data type value at ind

  • Can we just have the old numbers back?

    Ok so we have mavericks, please put numbers back with all the old options..... I am not techie I just want to use things intuitively the way SJ p,panned it.

  • Mouse pointer is frozen in left corner of monitor.  restarted, can't get it to move

    My Power Mac G-4's mouse indicator/pointer is frozen in  the upper left corner of the monitor.  I can't get it to move.  I have restarted, powered down, checked all connections to no avail.    Anybody have any ideas?  Thanks.