Call to super must be first statement

I'm new to Java and I have a question regarding super(). I'm implementing a design where we have a custom exception which extends Exception. The design calls for null messages to lead to throwing an IllegalArgumentException, but Exception's constructor does not throw an IllegalArgumentException for a null message.
Here is what I want to do, but not allowed to since super must be the first statement in the constructor:
public CustomException(String message) {
    if (message == null) {
        throw new IllegalArgumentException("message cannot be null.");
    super(message);
}I could call super first and then throw an exception if the message is null, but that doesn't seem like a good solution.

public CustomException(String message) {
    super(nullCheck(message));
static String nullCheck(String message) {
    if (message == null) {
        throw new IllegalArgumentException("message cannot be null.");
    return message;
}

Similar Messages

  • Call to super must be first statement in constructor

    Why i've receive this message if the code of the constructor is that:
    public void Angulo(String Base){
         super(Base);
    The call to superclass constructor is the first statement on this function.
    Can somebody helpme? Thanks

    Hi,
    This is a regular function and not a constructor. If it is, then it should be
    public Angulo(String Base){
    super(Base);
    Hope this helps,
    Kurt.

  • Again on "call to this must be first statement in constructor"

    Hi, I've spent the last hour reading tons of docs & threads about the "call to this must be first statement in constructor" problem, but I still cannot work it out.
    Here is the code
         public Orologio(String s)
              StringTokenizer exploder=new StringTokenizer(s,":",false);
              this(Integer.parseInt(exploder.nextToken()),Integer.parseInt(exploder.nextToken()));
              }Well, I know this..() must be the first line in the method, but I need to parse my input string before passing the parameters to the Orologio(int,int) constructor!
    Thankyou!

    You could define an initialization method:private void init(int a, int b) {
        ... your initialization code that was in your constructor...
    public Orologio(String s) {
        StringTokenizer exploder=new StringTokenizer(s,":",false);
        init(Integer.parseInt(exploder.nextToken()),Integer.parseInt(exploder.nextToken()));
    public Orlogio(int a, int b) {
        init(a, b);
    }However, make sure it is the responsability of this class to handle String as constructor parameter. Maybe you should force the client to tokenize the string and provide integer values to the constructor (and then get rid of the Orologio(String s) constructor.)

  • "call to this must be first statement in constructor"

    Here's the code:
    public class TAGEmail {
        private StringBuilder sTO = new StringBuilder();
        public TAGEmail()
        public void setTO(String sRecipient)
            this( sRecipient, true );
        public void setTO(String sRecipient, boolean bAppend)
            String sRegexPattern = "^[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}$";
            Pattern oPattern = Pattern.compile(sRegexPattern, Pattern.CASE_INSENSITIVE);
            Matcher oMatcher = oPattern.matcher(sRecipient);
            if( ! oMatcher.find() )
                oLogger.addEntry(2,"Email address '" + sRecipient + "' is not a valid e-mail address!");
            if( sTO.equals(null) || bAppend )
                sTO.append( "\"" + sRecipient + "\"" );
            else
                sTO.delete( 0, sTO.length() );
                sTO.append( "\"" + sRecipient + "\"" );
    }The part I don't get is that it's not in a constructor...and it is the first line of the method it's in. Am I missing something?

    Ah. My thought process was just the opposite. If
    the compiler is going to add it anyway, I'll just do
    it now. Symantics, I suppose.Well, the compiler doesn't add it into the source code. It simply interprets the two expressions identically. (It might be possible that something is hiding or shadowing the method so that this. is necessary for disambiguation. I've only seen that with variables though. I don't know if it can ever be an issue with methods. If it happens, I'd say something is poorly named.)

  • SET TRANSACTION must be first statement of transaction

    I am using oracle8i db with sun one 7.0. i use the oracle thin driver to talk to the db. i have bunch of session beans which uses the oracle data source. when i invoke the session bean, i get this ORA-01453 error.
    Here is my jdbc properties:
    <jdbc-connection-pool steady-pool-size="8" max-pool-size="32" max-wait-time-in-millis="60000" pool-resize-quantity="2" idle-timeout-in-seconds="300" is-isolation-level-guaranteed="true" is-connection-validation-required="true" connection-validation-method="table" fail-all-connections="false" datasource-classname="oracle.jdbc.xa.client.OracleXADataSource" name="JSBContainerPool" res-type="javax.sql.XADataSource" validation-table-name="dual" transaction-isolation-level="read-committed">
    <property value="jdbc:oracle:thin:@muruga:1521:DEV" name="URL"/>
    <property value="muruga" name="User"/>
    <property value="muruga" name="Password"/>
    </jdbc-connection-pool>
    <jdbc-resource enabled="true" pool-name="JSBContainerPool" jndi-name="jdbc/JSBContainerDataSource"/>
    Error message:
    The exception reported is: "java.sql.SQLException: ORA-01453: SET TRANSACTION
    must be first statement of transaction
    WARNING: CORE3283: stderr: at oracle.jdbc.dbaccess.DBError.throwSqlExceptio
    n(DBError.java:168)
    WARNING: CORE3283: stderr: at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.j
    ava:208)
    WARNING: CORE3283: stderr: at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:543
    WARNING: CORE3283: stderr: at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Pro
    tocol.java:1405)
    WARNING: CORE3283: stderr: at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFet
    ch(TTC7Protocol.java:822)
    WARNING: CORE3283: stderr: at oracle.jdbc.driver.OracleStatement.executeNon
    Query(OracleStatement.java:1446)
    WARNING: CORE3283: stderr: at oracle.jdbc.driver.OracleStatement.doExecuteO
    ther(OracleStatement.java:1371)
    WARNING: CORE3283: stderr: at oracle.jdbc.driver.OracleStatement.doExecuteW
    ithTimeout(OracleStatement.java:1900)
    WARNING: CORE3283: stderr: at oracle.jdbc.driver.OracleStatement.execute(Or
    acleStatement.java:737)
    WARNING: CORE3283: stderr: at oracle.jdbc.driver.OracleConnection.setTransa
    ctionIsolation(OracleConnection.java:1081)
    WARNING: CORE3283: stderr: at com.sun.enterprise.resource.Jdbc20XaAllocator
    $ConnectionWrapper.setTransactionIsolation(Jdbc20XaAllocator.java:196)

    In the connection pool setting in Admin server under the section Transaction Isolation deselect the option "Guarantee Isolation Level" .This should solve the problem.
    regards
    Kris

  • JdbcRowSetXImp (..): SET TRANSACTION must be first statement of transaction

    Hi.
    Im running JSC created application and getting in the log file this messages:
    [date & time] warning (24167): CORE3238: stderr: JdbcRowSetXImpl (setTransactionIsolation): [Sun][Oracle JDBC Driver][Oracle]ORA-01453: SET TRANSACTION must be the first statement of transaction
    As you may see, Im using JSC JDBC drivers. Im running on Sun One Web Server version 6.1 sp2 on Linux RedHat 3Ent. The application was builded with JSC me with latest patch applied.
    It seems a bug in the JdbcRowSetXImpl.
    Has someone similar problem?
    Regards.

    Hi John.
    This message is present on all log file a few days after the application began in production use, almost a month ago.
    The only change done in the configuration few days after the app was deployed was "Guarantee Isolation Level" in the JDBC connection pool configuration, switched from OFF to ON.
    Yesterday I turn OFF again and have no more messages about SET TRANSACTION...
    I guess that the SET TRANSACTION is issued two times, one by the web server before giving the connection to the app then by the row set impl.
    I will let you known if the messages appears again (I guess not).
    Regards.

  • Super- first statement in constructor.

    my compiler (Jcreator LE) doesn't seem to recognize that super is the first statement in the constructor, and gives me an error message (the same thing happens using the this keyword).
    public void Student(String str, int day, int mo, int yr, String maj)
    super(str,day,mo,yr);
         major=maj;
         return;
    With that code as the constructor, I get this error message
    C:\Java\JCreator le\MyProjects\Lab 5\Student.java:8: call to super must be first statement in constructor
              super(str,day,mo,yr);
    If anybody has any ideas why this is happening or what I can do to correct it, I would appreciate it.
    Thanks,
    Gareth

    You are trying to call a method.
    Instead you have to use super( ) to controll the construction
    of a parent class part of an object.
    Code is something like this:
    class Student {
      public Student(String str) {
         // initialize this object using str
      public Student(int day) {
        // initialize this object using day
    class FromStudent extends Student {
        public FromStudent(String str) {
           // pass control to Student constructor
           super(str);  // the first constructor here
        public FromStudent(int day) {
           // pass FromStudent to Student constructor
          super(day);  // the first constructor here

  • Any idea why super() and this() needs to be first statement

    Java recommends super() and this() to be the first statement to be used.why this design constraint is imposed?
    This imposes one more restriction
    where super() and this() cannot be used at the same time?
    how this constraint is useful.
    for eg:
    class A
         A(int a)
         System.out.println("A(int)");
         A(int a,int b)
         System.out.println("A(int,int)");
    class B extends A
         B()
              super(1);
              System.out.println("B()");
         B(int i)
              this();
              super(1,1);//compile-error :must be first statement
    the above eg may be a bad design,but are the constraints imposed for this purpose?or anything else?

    To make sure that the constructor is the first thing that runs, and to make sure >the super instance is completely constructed before we do anything with the >child instance.
    Both these go toward having the object be in a consistent, valid state.I accept the point,but considering the code part
    B()
       //super(1);
    System.out.println("B()");
    B(int i)
    super(1,1);
    this();
    }in above super instance will be constructed first followed by this().
    but this() cannot be used as second statement???
    I feel ,this is because this() in turn calls the super constructor again?to restrict this constraint made?is it something like that?

  • Super() constructor must be first. Is it right?

    My previous discussion abot the this issue has been removed. I must reconstruct it to be aware of advantages, disadvantages and bypasses over the restriction.
    Obvously, the restriction prevents us from writing some perfectly valid code:
    class Unsigned7BitOscillatorInputStream extends OscillatorInputStream {
         Unsigned7BitOscillatorInputStream(
              PeriodicSignal signal,
              float amplitude,
              float signalFrequency,
              AudioFormat f,
              long framesLength)
              // call super substituting the audio format
              super(
                   signal,
                   amplitude,
                   signalFrequency,
                   new AudioFormat(AudioFormat.Encoding.PCM_UNSIGNED,
                        f.getSampleRate(),
                        8, f.getChannels(),
                        f.getFrameSize(),
                        f.getFrameRate(),
                        false
                   framesLength);
         }It is the same if one writes
    class Unsigned7BitOscillatorInputStream extends OscillatorInputStream {
         Unsigned7BitOscillatorInputStream(
              PeriodicSignal signal,
              float amplitude,
              float signalFrequency,
              AudioFormat f,
              long framesLength)
              // create audio format for super class, overriding bps
              AudioFormat format = new AudioFormat(
                   AudioFormat.Encoding.PCM_UNSIGNED,
                   f.getSampleRate(),
                   8,
                   f.getChannels(),
                   f.getFrameSize(),
                   f.getFrameRate(),
                   false);
              super(signal, amplitude, signalFrequency, format, framesLength);
         }Fortunately, the new AudioFormat obect can be created inline with super call. Nevertheless, actually, anyway, the instantiation of the local object preceeds the super call. So what was the reason to prevent java programmers from writing strightforward code, make them decieving themselves and looking for ugly bypasses? What if some comuptation must be done and some fields initialized before super can be called? What if I want to log the arguments passed before calling the super constructor? I wonder how java designers know in which order the fields must be initialized/accessed. IMO, it is exactly constructor's competence.

    Java was specifically constructed with limitations in
    mind based on experience with common problem areas.
    Notice that I said "specifically".Does it mean they all the OOP practices are the best? Should I use them as a reference? Which kind of errors does it protect me from? I would like to see a document telling that calling super constructor is evil, really. Peahaps the reasons lie not in best OOP practice but rather some technical/historical sad fact. It would be amusing if you are defending somenes mistake. I'm sure is java did not initially had the real type (float point) for the reason of its support complexity, the java bigots today would prove that the real numbers are evil and the requirement to use this type in your program points to a flaw in your design. The paramount evidence on the best programming practices will, of course, be the JLS bible. Like they prove there must not be a Set.get(key) in the set class/interface. They tell me that there must be none need to request an object of the same class ("class" in math terms) equivalent to that one you have put into the set. They tell me that if I need the method, my design is flawed. However, actually, the lack of the method in java.collections is nothing more than their designer's mistake. The most obvious illustration are relational tables in DB: the keys are parts (fields, members) of records (entities, objects) while tables are nothing more than sets of objects. Using maps in this case is inappropriate and inferes redundancy. But that's another story... Though the superfirst requirement also adds the extra complexity and must be thoroghly justified. Any artifical overcomlication/redundancy must have a solid evidence. IMO, the objected limitation looks like a 5th wheel in a java-telega.
    I have programmed with gotos many years ago. My experiance proves the Dykstra's (one of the structural programming fathers) thesis stating the "gotos are evil". The gotos break the flow of control making it hard to follow. Therefore, I readitly accept it. I have never seen the thesis, but I'm sure I can find and refer it to you if you like. At the same time, I'm sure there is nothing similiar in OOP domain telling the "deferred" supercons are evil. Otherwise, you would be more specific in references. Suppose, someone confines you into a prison, argumenting this is a "specific tool/limitation" to prevent "some" problems. Will you agree? You will insist on some more serious criminations? Be happy - they tell you - you are allowed to argument against the confinement appealing to our community (the community are the people believing the authority blindly)! No, it is accepted in justice that any limitation of freedom must be justified, not the contrary! This is called a presumption of innocence. I suffer, I break my mind when I know that the following invocations are the same but the second does not work for some queer reason:
              B() {
              super(computePrereq());
         B() {
              r = computePrereq(); // why this is worse than above? Where is the justice?
              super(r);
    I think you can find more than a couple of C++
    best practices books and articles that will tell
    you how C++ constructors should be built.Wow, you refer me to C++ as a citadel for OOP best practices! OK. CPP::STL "package" has the get_by_key method in the Set class/template. Will this fact chagne the mind of java bigots? Obviously not, they immediately refuse your arguments just hearing c++. I can, but just please be more specific. I may to carefully explore a ton of books without finding any sign of super second is evil.
    My favorite lang on Wintel platform is Delphi. Many thoughtful people consider it as a Wintel native java. However, there is even no recommendation to use superconstructors first. And the broad experience suggests me that there is nothing harmful in deferring the superconstruction. I do not feel any nasty frustration similar to exploiting gotos. The super destructors must be called last indeed, since they ultimately call the root superclass's (TObject) destructor, which deallocs the mem and the object ceases to exist after the call. But constructors do not alloc any mem for the object fields, they just fill the fields. The order of initialization is absolutely free. The initialization of all the fields may even be made in parallel for performance.
    Delphi also has a interface-resolution mechanism. Two interfaces conflict when they specify two aliasing methods. Will you tell that it is a bad design if happens that two interfaces conflict? The Divide&Concure disign rule tells the contrary, it is bad design when you must care about other blocks developing one. It is java which has design flaw - you must care about names of methods in other interfaces. This is the experiance collected from wast SW/HW methodologies I can share with java community.
    Show me why I cannot construct a human without
    first
    producing an ape?
    False analogy. I doubt that anyone would ever
    construct an inheritence hierarchy like that.I do not belive in God either ;)
    The evolution took itself.
    Or construct a tree without first
    producing a plant? And that would be logically inconsistent. A tree is
    a plant. If plant does not exist then a tree can not
    either.OK. Which plant should I create before proceeding to construct a tree? Do you understand that the Plant and Tree are the classes while an instance of the Tree just belongs to these classes? The calsses are loaded prior to construction. Now, I'm creating a tree. It is not your matter how the tree is created. You just get a tree and if it is a valid tree; that is, your tree implements all methods of the interface the tree class commits to implement, then it is also a plant. The construction technology is not important. The constructor knows it better when to create a steam and leafs.
    Your analogies are a bit absurd. There are other
    more relevent ones though...
    Employee (parent) -> surpervisor (child).
    Based on your argument it is stupid to have a
    supervisor who is an employee. Whereas in the world
    I live in the vast majority of the time supervisors
    are employees. And in the cases where they aren't
    (rare contractual situations) then building a
    hierarchy that reflects that relationship is a design
    flaw which has nothing to do with construction.Where did I argument against this relatioship? Nevertheless, if it bothers you I can tell you my opinion. In the manager-workers pattern, the emploee (also called a manager) is a job, whos duty consists of finding the workers, hand out a job to them and accepting (supervising) the work done. It may also stimulate/motivate the workers, but that is not important. What's more important is that the surpervision is one of manager's duties. Any Manager is a supervisor by definition. Thus, I can explain why Ape and Human are two different classes in the ancestor-descendant relationship, but I cannot explain you manager-supervisor subclassing... I would establish an Employee class implementing its duty interfaces listed. At least, since multiinheritance is not supported in java and you'll have a problem deriving the Emploee from both task initiator and inspector. If you like.
    The plant appears
    altogether with a tree. Talking in a scientigic
    language, being a plant is nothing more than an
    attribute of a tree (which cannot appearahead of the
    object). They appear simultaneously and are
    indistinguishble as a single whole.You said it not me. If you are using attributes and
    nothing else to construct inheritence then your
    design is flawed.Excuse me for not understanding/appretiating your humor. The "Tree" objects are attributed to "Plants" class. Don't you agree of what?
    To put it bluntly, this is you who seem to use inappropriete terminology. In programming, the parent-children relationship is used for tree structures (has-a). Parent may have (or own) a set of children. However, no parent construction precedes the construction of every "child" object. Otherwise, we would get too many parents. While we need descedants. The descedants have attributes of parents but they are not separate objects. Like keyfields in a DB records. All the fields are equal (if we do not toudch the pragmatic level). The ancestor-descendant terminology is adoped in OOP (the talks about inheritance). In java, super/sub-class notation is accustomed. This sharpens my confusion on which "parents" should I create before initializing any new object specific fields.
    Looks like a demagogic sentence. Let's think of a
    human as a brain-increased ape without tail. Do
    again?) or proceeded directly?
    Again you are using a very bad example for
    inheritence.I fail to see why the natural exapmles of inheritance are somehow "bad". OK, not all apes are brain-low, since humen break this rule.
    No, but I can make a soudspeaker without bringingits
    "parent" (presumably, a soundsystem) into "a valid
    state". I can write a java program withoutbringing
    some "abstract" program into a valid state.
    Even worse example. A "sound system" is a
    collection of other objects.
    There is no way that a speaker is ever a child or a
    parent of an amplifier.Thereofore, an abstract soundsystem may not have any concrete descendants? A soundsystem consumes a stream of databits or continous electric signal and produces sound waves. A laudspeaker near to me is full of controls - volume, bass, ets.. What is it if not an incarnation of a sound system?
    OK, here is another example. A floppy-disk is a disk. Should one produce a disk before making it floppy? Or microwave owen is an owen. How do you think should I create an owen prior to making it a microwave? Or electric field, how do I create a field prior to adding the electric parameters? Or how do I construct a hammer if you require me to precede its construction by construction of abstract instrument? How do I manufacturers produce "parent" computers before attaching "personal" properties to it? I'm sure there are millions of ways to construct a PC but none of them requires producing some "parent".
    OK, which chapter of CS tells that "parents" mustbe
    created prior to a "children"? Should Intel start
    manufacturning their Pentium chips by producing8088
    core first? I am beginning to think that you have a substantially
    different view than most people about what
    inheritence means.
    I find it hard to believe that anyone, in any
    situation, would ever attempt to create an
    inheritence tree using 8080 as the parent and a
    pentium as the child. This is a historical
    relationship not a child parent one.The Pentioum extends functionality of 8088 (both HW and SW). Engeneers started more and more features at the core. Finally they got a huge monster. It still starts as 8088. A program can call for extended capabilities if it knows about them. The old programs work on Pentium using its 8088 inherited interface.
    What do you mean telling "parent in valid
    state"? In construction, only ONE object isproduced,
    which complies to its ancestor interface.
    Constructors just aid the process. May be youwanted
    to tell there is no analogy between OOP and the
    nature?A tree is a plant. It is nonsense to suggest that a
    tree can exist before plant exists.As I have told, I have never suggested for such a nonsense. The Plant class exits long before you create an instance of a tree.
    That has nothing to do with the relationship between
    an acorn and an oak however. Nor does the fact that
    an oak produces acorns mean that there is a child
    parent relationship in terms of OO in there.I have never told that the seeds are plants. Moreover, I do not see any relation here with your proir argument that the creation of instance of an oak must be preceeded by the creation of instantance of some abstract plant (belonging to a Plant class) and the tree instance constructor then must decorate the the basic structure of that plant instance.
    Please refer me to a book telling that fields of superclass must be initialized prior to (not after and not concurrently) with the new fields exposed by a subclass.

  • SQLException: After clearParameters() has been called, all parameters must be reset before executing

    Hi,
    I am running: Weblogic 6.1, SP2
    Driver : weblogic.jdbc.oci.Driver
    Reason for not using the "thin" driver, which works, is limit
    on size of Clob
    Previous references to this problem in this newsgroup indicate driver problems
    with older versions of WL.. I am using the latest..
    The SQLException I get is "After clearParameters() has been called, all parameters
    must be reset before executing". This happens the second time the code below is
    excuted ( ok the first time )
    "clearParameters()" is never called explicitly in my code.
    The exception occurs on the "spFunc.execute();" statement at the very end of this
    code:
    // OBS:connection, conn_, is opened from a connection pool
    before this code is called and cloesed afterwards.
    conn_.setAutoCommit(false);
    // ============== Initializing clob ==================
    SerialStatement stmt = (SerialStatement)conn_.createStatement();
    stmt.execute("INSERT INTO lc_clob_temp VALUES (1, EMPTY_CLOB())");
    // OBS: using a prepared statement here will result in SerialClob
    // exception when using setClob in the prepared statement
    below
    // This is probably a bug ( worked in WL 5.1 ). We had this
    as a support case 270952 with WebLogic.
    stmt.execute("SELECT * FROM lc_clob_temp WHERE id = 1");
    ResultSet crs = stmt.getResultSet();
    weblogic.jdbc.rmi.SerialClob xmlClob = null;
    while ( crs.next() ) {
    xmlClob=(weblogic.jdbc.rmi.SerialClob)crs.getClob("newclob");
    // Call Oracle's stored procedure for calling Oracle XSU.
    SerialCallableStatement spFunc =
    (SerialCallableStatement)conn_.prepareCall(
    "declare " +
    "insCtx sys.DBMS_XMLSave.ctxType; " +
    "begin " +
    "insCtx := sys.DBMS_XMLSave.newContext(?); " +
         "sys.DBMS_XMLSave.setBatchSize(insCtx,0);" +      "sys.DBMS_XMLSave.setCommitBatch(insCtx,
    0);" +
    "? := sys.DBMS_XMLSave.insertXML(insCtx,?); " +
    "sys.DBMS_XMLSave.closeContext(insCtx); " +
    "end;"
    spFunc.setString(1, viewName );
    spFunc.registerOutParameter (2, Types.NUMERIC);
    Writer outstream = xmlClob.getCharacterOutputStream();
    outstream.write(xml.toString());
    outstream.flush();
    outstream.close();
    spFunc.setClob( 3, xmlClob);
    spFunc.execute();
    spFunc.close();

    Hi,
    I am running: Weblogic 6.1, SP2
    Driver : weblogic.jdbc.oci.Driver
    Reason for not using the "thin" driver, which works, is limit
    on size of Clob
    Previous references to this problem in this newsgroup indicate driver problems
    with older versions of WL.. I am using the latest..
    The SQLException I get is "After clearParameters() has been called, all parameters
    must be reset before executing". This happens the second time the code below is
    excuted ( ok the first time )
    "clearParameters()" is never called explicitly in my code.
    The exception occurs on the "spFunc.execute();" statement at the very end of this
    code:
    // OBS:connection, conn_, is opened from a connection pool
    before this code is called and cloesed afterwards.
    conn_.setAutoCommit(false);
    // ============== Initializing clob ==================
    SerialStatement stmt = (SerialStatement)conn_.createStatement();
    stmt.execute("INSERT INTO lc_clob_temp VALUES (1, EMPTY_CLOB())");
    // OBS: using a prepared statement here will result in SerialClob
    // exception when using setClob in the prepared statement
    below
    // This is probably a bug ( worked in WL 5.1 ). We had this
    as a support case 270952 with WebLogic.
    stmt.execute("SELECT * FROM lc_clob_temp WHERE id = 1");
    ResultSet crs = stmt.getResultSet();
    weblogic.jdbc.rmi.SerialClob xmlClob = null;
    while ( crs.next() ) {
    xmlClob=(weblogic.jdbc.rmi.SerialClob)crs.getClob("newclob");
    // Call Oracle's stored procedure for calling Oracle XSU.
    SerialCallableStatement spFunc =
    (SerialCallableStatement)conn_.prepareCall(
    "declare " +
    "insCtx sys.DBMS_XMLSave.ctxType; " +
    "begin " +
    "insCtx := sys.DBMS_XMLSave.newContext(?); " +
         "sys.DBMS_XMLSave.setBatchSize(insCtx,0);" +      "sys.DBMS_XMLSave.setCommitBatch(insCtx,
    0);" +
    "? := sys.DBMS_XMLSave.insertXML(insCtx,?); " +
    "sys.DBMS_XMLSave.closeContext(insCtx); " +
    "end;"
    spFunc.setString(1, viewName );
    spFunc.registerOutParameter (2, Types.NUMERIC);
    Writer outstream = xmlClob.getCharacterOutputStream();
    outstream.write(xml.toString());
    outstream.flush();
    outstream.close();
    spFunc.setClob( 3, xmlClob);
    spFunc.execute();
    spFunc.close();

  • CALL TRANSACTION 'VA02' AND SKIP FIRST SCREEN?

    Hi, Gurus:
    In my program, after I call 'CALL TRANSACTION 'VA02' AND SKIP FIRST SCREEN.'    in the va02, user maybe do some change and save
    then I want to get those change as the dollowing:
        select single uvall into c_complete_flag from vbuk
         where vbeln = lv_vbeln.
    why I can't get the latest change.
    Thanks,

    VA02 usese the asynchronus update mehtod so, it gives you the message like "Order 1111 was saved" but the database update is still going on.
    So, you need to wait for some time before facthing the data from the database.
    You can use like:
    WAIT UP TO 10 SECONDS.
    But this statement will force you to wait for atleast 10 seconds before doing any thing.
    Regards,
    Naimesh Patel

  • Two statements, get results from the first statement?

    Ok maybe I made it sound a little harder than it is, but this is what I am trying to do. I have a result set from from a database call when I pass in the username and password . In the 1st call I get the Users info: User_ID, first_name, lastname, etc...
    But I either need to get info from the first statement, and pass it to the 2nd statement or just do two statement calls calling the same info and passing it to my user object? I dont know which if any is faster, or better. The only thing I need from the first statement is the user_id. In the 2nd statement I need the user_id to find out the user permissions.
    Here is the original code when It was getting the user info and permissions from the same table. try
               dba = new DbAccess();
               java.sql.Connection con = dba.getConnection();          
    java.sql.DriverManager.getConnection("jdbc:oracle:thin:@kares:1523:appd","user","pass");  
               ps = con.prepareStatement("SELECT USER_ID, LAST_NAME, FIRST_NAME, LOGIN, PASSWORD," +
               "X, Y, Z FROM RD_USERS WHERE LOGIN=? and PASSWORD=?");
               ps.setString(1, user);
               ps.setString(2, pass);
               rs = ps.executeQuery();
               // set the user attributes
               if ( rs.next() )
                  loginValid = true;
                  setUserId(rs.getInt("USER_ID"));
                  setLastName(rs.getString("LAST_NAME"));
                  setFirstName(rs.getString("FIRST_NAME"));
                  setLoginName(rs.getString("LOGIN"));
                  setPassword(rs.getString("PASSWORD"));   
                  X = rs.getBoolean("X");
                  setX(X);
                  Y = rs.getBoolean("Y");
                  setY(Y);
                  Z = rs.getBoolean("Z");
                  setZ(Z);
               else
                  setLastName(null);
                  setFirstName(null);
                  setLoginName(null);
                  setPassword(null);
                  setX(false);
                  setY(false);
                  setZ(false);
               rs.close(); rs = null;
               ps.close(); ps = null;
               //dba.close(); dba = null;
            } The code above gets the info from one table, I now need to get the X, Y, and Z from a different table, but I need the USER_ID first. So, the first table is set up with the user_id and user info, and the 2nd table is set up with the user_id and user permissions

    Thanks DrClap I started on the the query and I did it a little differently, but it should hopefull do the same thing. my tables are constructed as so:
    USER
         USER_ID
         FIRST_NAME
         LAST_NAME
         USER_NAME
         PASSWORD
         ETC....
    USER_PERMISSIONS
         USER_ID
         PERMISSION X
         PERMISSION Y
         PERMISSION Z
         ETC....
    My Select looks something like this
    ps = con.prepareStatement("SELECT a.USER_ID, a.LAST_NAME, a.FIRST_NAME, a.USER_NAME, a.USER_PASSWORD," +
               "b.X, b.Y, b.Z FROM RD_USERS a, RD_PERMISSIONS b WHERE USER_NAME=? and USER_PASSWORD=?");
    This is where I come to a crossroads, Can I add on another AND to say "WHERE a.USER_ID = b.USER_ID
    and do I use the =, or is it ==, or .equals(). Thanks in advance.
    orozcom

  • CALL TRANSACTION 'MIR6' AND SKIP FIRST SCREEN .

    Hi all,
    i hope there is someone that can help me.
    My problem is: in an ABAP custom report in a FORM user-command my code is
      CASE ls_selfield-sel_tab_field.
        WHEN 'ITAB-BELNR'.
          IF NOT ls_selfield-value IS INITIAL.
            SET PARAMETER ID 'RBN' FIELD ls_selfield-value.
            CALL TRANSACTION 'MIR6' AND SKIP FIRST SCREEN .
      ENDCASE.
    When i click on output field of my report, not skip first screen but only call MIR6!!!
    How can i solve this problem? 
    Regards.

    Hi,
    First of all Please don't use all Caps for Subject Line
    Test Following Sample Code it will solve out your problem,
    DATA: it_bdcdata TYPE TABLE OF bdcdata,
          wa_it_bdcdata LIKE LINE OF it_bdcdata,
          belnr(10).
    belnr = '100'. " Give Document Number here
    DATA opt TYPE ctu_params.
    CLEAR wa_it_bdcdata.
    wa_it_bdcdata-program  = 'SAPMM08N'.
    wa_it_bdcdata-dynpro   = '100'.
    wa_it_bdcdata-dynbegin = 'X'.
    APPEND wa_it_bdcdata TO it_bdcdata.
    CLEAR wa_it_bdcdata.
    wa_it_bdcdata-fnam = 'BDC_CURSOR'.
    wa_it_bdcdata-fval = 'SO_BELNR-LOW'.
    APPEND wa_it_bdcdata TO it_bdcdata.
    CLEAR wa_it_bdcdata.
    wa_it_bdcdata-fnam = 'SO_BELNR-LOW'.
    wa_it_bdcdata-fval = BELNR.
    APPEND wa_it_bdcdata TO it_bdcdata.
    CLEAR wa_it_bdcdata.
    wa_it_bdcdata-fnam = 'BDC_OKCODE'.
    wa_it_bdcdata-fval = '=CRET'.
    APPEND wa_it_bdcdata TO it_bdcdata.
    opt-dismode = 'E'.
    CALL TRANSACTION 'MIR6' USING it_bdcdata OPTIONS FROM opt.
    Please Reply if any Issue,
    Best Regards,
    Faisal

  • Call transaction 'LS33' and skip first screen.

    This doesn't work:
    set parameter id 'LEN' field '04018091'.
    call transaction 'LS33' and skip first screen.
    I've found this:
    <a href="https://www.sdn.sap.com/irj/sdn/message?messageID=3715690">https://www.sdn.sap.com/irj/sdn/message?messageID=3715690</a>
    but I'm not sure about the exact meaning (wouldn't know where to put the *)
    nor even about if it applies.
    Thanks in advance.

    Sorry, I mistook this forum for that of ABAP General.
    Anyway, the answer is in
    Call transaction 'LS33' and skip first screen.

  • CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.

    Hi,
    i'm using this in an report.
    SET PARAMETER ID 'BES' FIELD WA_ITAB-EBELN.
    SET PARAMETER ID 'BSP' FIELD WA_ITAB-EBELP.
    CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.
    It works OK.
    Is there any parameter ID to go in a sprecial part of an PO, for example
    direct to materialdata or konditions?.
    thanks.
    Regards, Dieter

    Hi,
    I think u can do that by using BDC as used in this code please refer to this code.
    FORM get_user_command USING cr_ucomm     LIKE sy-ucomm      "#EC *
                                cr_selfield TYPE slis_selfield.
      CLEAR wa_final.
      DATA BEGIN OF bdcdata OCCURS 10.
              INCLUDE STRUCTURE bdcdata.
      DATA END OF bdcdata.
      CASE cr_ucomm.
        WHEN '&IC1'.
          READ TABLE it_final INTO wa_final
                   INDEX cr_selfield-tabindex.
          IF cr_selfield-fieldname = 'MATNR'.
            IF sy-subrc IS INITIAL.
              SET PARAMETER ID 'MXX' FIELD 'E'.
              SET PARAMETER ID 'MAT' FIELD wa_final-matnr.
              SET PARAMETER ID 'WRK' FIELD wa_final-werks.
              CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN.
            ENDIF.
          ELSEIF cr_selfield-fieldname = 'LIFNR'.
            IF sy-subrc IS INITIAL.
              CLEAR bdcdata.
              bdcdata-program  = 'SAPMF02K'.
              bdcdata-dynpro   = '0101'.
              bdcdata-dynbegin = 'X'.
              APPEND bdcdata.
              CLEAR bdcdata.
              bdcdata-fnam     = 'RF02K-LIFNR'.
              bdcdata-fval     = wa_final-lifnr.
              APPEND bdcdata.
              CLEAR bdcdata.
              bdcdata-fnam     = 'RF02K-EKORG '.
              bdcdata-fval     = wa_final-ekorg.
              APPEND bdcdata.
              CLEAR bdcdata.
              bdcdata-fnam     = 'RF02K-D0310'.
              bdcdata-fval     = 'X'.
              APPEND bdcdata.
              CLEAR bdcdata.
              bdcdata-fnam     = 'WRF02K-D0320'.
              bdcdata-fval     = 'X'.
              APPEND bdcdata.
              CLEAR bdcdata.
              bdcdata-fnam     = 'BDC_OKCODE'.
              bdcdata-fval     = '/00'.
              APPEND bdcdata.
              CLEAR bdcdata.
              bdcdata-program  = 'SAPMF02K'.
              bdcdata-dynpro   = '0110'.
              bdcdata-dynbegin = 'X'.
              APPEND bdcdata.
              CALL TRANSACTION 'XK03' USING bdcdata MODE 'E'.
            ENDIF.
          ENDIF.
      ENDCASE.
    ENDFORM.  " get_user_command
    regards,
    sudha

Maybe you are looking for

  • Google calendar iPhone sync issue

    Unable to uncheck a calendar in the iPhone google calendar sync menu. Keep receiving notifications linked to this calendar even though I have disabled notifications.

  • Convert XML string into an abap format date and time

    Hi, Does anyone know of a method or a function module in ABAP which converts XML string into an abap format date and time. Here is a part of the xml that I want to convert. <ns2:EventDateTime>2009-07-02T10:13:45+10:00</ns2:EventDateTime> <ns2:EventMe

  • Download trial error

    Hi! I'm trying to download a trial of InDesign and the Adobe page states that it is "downloading now", but there has been no change in this status nor any pop-up or block that I can see that needs actioning. I've restarted the process once (full comp

  • GPO and Service SID?

      Hi, I'm a DBA installing SQL Server 2012.  SQL Server setup is creating service SIDs (e.g., NT SERVICE\MSSQLSERVER, NT SERVICE\MsDtsServer110, etc.) and granting them rights (e.g., SeServiceLogonRight, SeAssignPrimaryTokenPrivilege, etc.).  Our GPO

  • Product set types

    Hi forum, I want to relationate a product with the set types...i dont know how.. Anybody knows the table or the function i have to use..¿? Thanks in advance, Mon