Using "this" keyword

Please help me. I didn't find an explanation in manuals or tutorials. Thank you
//THIS PROGRAM IS WORKING BUT I CANNOT UNDERSTAND IT
class one{
     public one(){
     System.out.println("This is from constructor");
     //PLEASE MAKE ME UNDERSTAND THIS METHOD IN THE WAY IT IS DECLARED "one two()"!!!!!!!!
     //I'M ALSO CONFUSED ABOUT THE USE OF "THIS" KEYWORD
     one two(){
          System.out.println("This is from method two()");
          return this;
class From_main{
     public static void main(String[] args){
          one a=new one();
          one b=new one();
          a.two();
          b.two();
     }

IMHO the trouble with cute trivial Examples like this is that; the names are meaningless and/or tend to confuse
and they don't represent anything useful that you might do in real life.
It might help if we renamed the class and methods and added some comments
class Trivial {
  public Trivial(){
    System.out.println("This is from constructor");
  /** Returns a reference to an instance of this class */
  Trivial getInstance(){
    System.out.println("This is from method getInstance()");
    return this;
class From_main {
  public static void main(String[] args){
    Trivial a = new Trivial();
    Trivial b = new Trivial();
    Trivial aa = a.getInstance();
    // a and aa point to the same 'Trivial' instance
    if ( a == aa)
      System.out.println("a == aa");
    Trivial bb = b.getInstance();
    // b and bb point to the same 'Trivial' instance
    if ( b == bb)
      System.out.println("b == bb");
}The method getInstance() is redundant as you have to have a reference to the object
before you can invoke the method to get a reference to the object.
There are better ways to illustrate how to use the 'this' keyword.

Similar Messages

  • Can i use " this " keyword in session bean.

    Hi,
    I am working with session beans, in my business logic i need to use " this" keyword,
    but is it possible to use " this" keyword in EJB bean?.

    you can.
    do it !

  • When to use 'this' keyword

    Hi,
    I saw some code for a class which extended JFrame
    at the end of the constructor it says:
    this.setVisible(true);
    but of course it works when we have just:
    setVisible(true);
    I know how to use 'this' in other ways but what is the point of having it here
    Cheers
    Jim

    'this' is used for making differences between class variables and local variables.
    public class Test {
    private int value;
    public void setValue(int value) {
    this.value=value;
    regards
    Stas

  • Using the 'this' keyword

    What is the use of the this keyword:
    import java.util.*;
    public abstract class LegalEntity implements HasAddress{
    private String address;
    private String area;
    private String registrationDate;
    private ArrayList accounts;
    public LegalEntity()
         accounts = new ArrayList();
    public void addAddress(String address){this.address = address;}
    public String getAddress(){return address;}
    public void addAccount(Account account)
         accounts.add(account);
    public ArrayList returnAccounts()
         return accounts;
    }

    This can be used when there are lots of static functions and you want to be sure you are invoking the current objects methods/members.

  • I have the current iPhoto when I try to open it I get an error message You can't open your current photo library using this version of iPhoto

    You can’t open your current photo library using this version of iPhoto.
    I am using the current iPhoto and O/S 10.8.2

    Make a temporary, backup copy of your library if you don't already have one (Control-click on the library and select Duplicate from the contextual menu) and  apply the two fixes below in order as needed:
    Fix #1
    Launch iPhoto with the Command+Option keys held down and rebuild the library.
    Select the options identified in the screenshot. 
    Fix #2
    Using iPhoto Library Manager  to Rebuild Your iPhoto Library
    Download iPhoto Library Manager and launch.
    Click on the Add Library button, navigate to your Home/Pictures folder and select your iPhoto Library folder.
    Now that the library is listed in the left hand pane of iPLM, click on your library and go to the File ➙ Rebuild Library menu option
    In the next  window name the new library and select the location you want it to be placed.
    Click on the Create button.
    Note: This creates a new library based on the LIbraryData.xml file in the library and will recover Events, Albums, keywords, titles and comments but not books, calendars or slideshows. The original library will be left untouched for further attempts at fixing the problem or in case the rebuilt library is not satisfactory.
    OT

  • Can't open current photo library using this version of iPhoto 7.1.5

    I have recently had to perform a disk repair due to the disk image not mounting. In this process I completed a full backup of my home folder and verify/repair/format of my harddrive. At this time I also added 4G RAM bringing the MacBook up to 5G RAM.
    Since the reinstallation of 10.7.5 (Which took about 18hrs) I have none of the iLife package. I have reinstalled from the original disk that I recieved on initial purchase back in 2008. After installation I ran the software update and have updated everything (iTunes, iPhoto etc) I have been able to import all data from my backup via a simple drag & drop. I am now unable to open my iPhoto library (file size 105.43G). I have searched many forums and have been unable to find a solution that is suitable (rebuild library) because as soon as I launch this option it brings up the following message:
    You can’t open your current photo library using this version of iPhoto. You have made changes to your photo library using a newer version of iPhoto. Please quit and use the latest version of iPhoto.
    After this I must quit the application. What am I missing? I'm sure it is something quite simple... I'm hoping it is as easy as it was to find the recoveryHD during the reformat of the disk.
    Any help would be greatly appreciated, Cheers.

    It sounds like a damaged library. Try the 2 fixes below in order as needed:
    Fix #1
    Launch iPhoto with the Command+Option keys depressed and follow the instructions to rebuild the library. Select the last three options.
    Fix #2
    Rebuild the library using iPhoto Library Manager as follows:
    Using iPhoto Library Manager to Rebuild Your iPhoto Library
    1 -Download iPhoto Library Manager and launch.
    2 -Click on the Add Library button, navigate to your User/Pictures folder and select your iPhoto Library folder.
    3 - Now that the library is listed in the left hand pane of iPLM, click on your library and go to the File->Rebuild Library menu option
    4 - In the next window name the new library and select the location you want it to be placed.
    5 - Click on the Create button.
    Note: This creates a new library based on the LIbraryData.xml file in the library and will recover Events, Albums, keywords, titles and comments but not books, calendars or slideshows. The original library will be untouched for further attempts at fixing or in case the rebuilt library is not satisfactory.

  • Yet AGAIN! "You can't open your current photo library using this version of iPhoto"

    I have read every thread on this topic I could find in these forums, and tried most solutions, and I still can't get iPhoto to work. 
    Equipment:  MacBook Pro June 2010, OS 10.6.8.  Bought a Macbook Air February 2012, OS 10.7.2
    Not sure why, but I can't open iPhoto.  Here's what I have tried.
    Original message on MBPro:  "You can’t open your current photo library using this version of iPhoto". 
    1.  Tried to rebuild library as per this thread https://discussions.apple.com/message/8429269#8429269.  I get the list of checkboxes, but when I hit "okay" I get the same "you can't open your current photo library ..." message again.
    2.  Ran software update - no sign that iPhoto is out of date.
    3.  Copied new version of iPhoto from brand new MBAir to MBPro, replacing older version .  Got same "you can't open your current photo library ..." message again.
    4.  Tried to rebuild library using new version of iPhoto - guess what - same message.
    5.  Downloaded free trial version of iPhoto Library Manager as suggested in the thread referenced above.  The dmg loads to my desktop just fine but nothing happens when I click on it -- this has never happened before.  Perhaps it is looking for iPhoto, which of course I can't get to work.
    So I have been unable to access my old iPhoto library with (sob) thousands and thousands of family photos in it.  I run TimeMachine on to an external hard drive every hour so I hope that if my iPhoto library is corrupted, there is a safe copy on that external drive ...
    Between this hassle -- hours of time wasted -- and recent debacle of upgrading iTunes which erased my library and all of my playlists, which also took hours and hours to restore ... my 25 year devotion to Apple products is taking a major hit.  I'm getting very weary of heart-pounding fear every time a new software upgrade arrives ... but that's a topic for another time. ;-)
    Thank you very much indeed for all suggestions.

    I'm going to start from scratch as  the link you references is very, very old.
    Try this:  launch iPhoto with the Option key held down and try to create a new, test library and import some photos. If you are able to then the problem lies with your current library. If you get the same message then maybe the iPhoto application is the problem.
    Try the following again:  make a temporary, backup copy (if you don't already have a backup copy)  of your library and apply the three fixes in order as necessary.
    Fix #1
    1 - delete the iPhoto preference file, com.apple.iPhoto.plist, that resides in your HD/User/Home()/ Library/Preferences folder.
    2 - delete iPhoto's cache file, Cache.db, that is located in your HD/User/Home()/Library /Caches/com.apple.iPhoto folder. 
    3 - launch iPhoto and try again.
    NOTE: If you're moved your library from its default location in your Home/Pictures folder you will have to point iPhoto to its new location when you next open iPhoto by holding down the Option key when launching iPhoto.  You'll also have to reset the iPhoto's various preferences.
    Fix #2
    Launch iPhoto with the Command+Option keys held down and rebuild the library.
    Select the options identified in the screenshot. 
    Fix #3
    Using iPhoto Library Manager  to Rebuild Your iPhoto Library
    Download iPhoto Library Manager and launch.
    Click on the Add Library button, navigate to your Home/Pictures folder and select your iPhoto Library folder.
    Now that the library is listed in the left hand pane of iPLM, click on your library and go to the File ➙ Rebuild Library menu option
    In the next  window name the new library and select the location you want it to be placed.
    Click on the Create button.
    Note: This creates a new library based on the LIbraryData.xml file in the library and will recover Events, Albums, keywords, titles and comments but not books, calendars or slideshows. The original library will be left untouched for further attempts at fixing the problem or in case the rebuilt library is not satisfactory.
    If all of these fail there's one more option:
    Start over from scratch with new library
    Start over with a new library and import the Originals (iPhoto 09 and earlier) or the Masters (iPhoto 11) folder from your original library as follows:
    1.  Move the existing library folder to the desktop.
    2. Open the library package like this.
    Click to view full size
    3. Launch iPhoto and, when asked, select the option to create a new library.
    4. Drag the each subfolder in the Originals folder (iPhoto 09 and earlier) or the entire Masters (iPhoto 11) folder from the iPhoto Library on the desktop into the open iPhoto window.
    Click to view full size
    This will create a new library with the same Events as the original library but will not keep the metadata, albums, books slideshows and other projects.
    OT

  • How do I filter photos using the keyword hierarchy?

    Since Aperture 3.1 came out, I've been taking another look at it and considering switching back from Lightroom. One baby step was to set up a proper keyword hierarchy with Aperture. Trying to use that for sorting photos, I started feeling incredibly frustrated and felt like I must be missing something screamingly obvious.
    Here's my issue. Using the keyword HUD, I can set up a nested, hierarchical keyword list. The HUD helpfully displays a running tally of all photos that keyword is applied to. "Great!" I thought, I've got 46 photos of John Smith, let's take a look at them. So I click on the number. Apparently, while Aperture is happy to show you the number of photos with the keyword, it's not willing to take you to those photos (i.e., create a library filter and show the results) via the Keyword HUD.
    Bringing up the filter HUD seems unhelpful for the opposite reason. While you can search via the keywords there, it doesn't show the keyword hierarchy! Am I missing something? Say I've got keywords for two people, Adam and Zoe, filed under People/Friends/. Using the keyword box in the filter HUD will list one at the beginning and the other at the end of my entire list of keywords. Worse, the filter HUD only seems helpful for keywords if you know which ones you're looking for, which defeats the point of using a hierarchy. If, say, I know there's 3 or 4 people I'm looking for under a particular category, but I can't remember their name of the top of my head, how do I go about finding them using the filter HUD? All I have is the long, uncategorized master list of keywords.
    Again, I feel I must be missing something obvious. Thanks for your help.
    Cheers.

    I agree, clicking on a keyword in the HUD that has a number after it to get those photos seems like a no brainer. Even though I know it doesn't do that I still find myself clicking on it before I catch myself. Need to send feedback to Apple on this, clicking on a keyword should create a filter to and display those images.
    In your example the images of Adam and Zoe should be tagged with the keywords that apply to them. That is they would have the keywords people, friends, male or female, Adam or Zoe, and whatever other keywords you use to describe these images. Then you check as many keywords in the filter that apply and you can remember.
    While the keyword HUD shows the keywords in a hierarchy, keywords applied to an image are one dimensional, linear. Its just a string of words without structure. The hierarchy is just there to make it easier to conceptualize the structure.

  • You can't open photo library using this version of iphoto. you have made changes to your photo library using a newer version of iphoto. please quit and use the latest version of iphoto

    you can't open photo library using this version of iphoto. you have made changes to your photo library using a newer version of iphoto. please quit and use latest version of iphoto. iphoto 11 is installed.

    This is a message you got?
    If so, as your post isn't clear, it may be a bogus message caused by a corrupt database.
    Option 1
    Back Up and try rebuild the library: hold down the command and option (or alt) keys while launching iPhoto. Use the resulting dialogue to rebuild. Choose to Rebuild iPhoto Library Database from automatic backup.
    If that fails:
    Option 2
    Download iPhoto Library Manager and use its rebuild function. This will create a new library based on data in the albumdata.xml file. Not everything will be brought over - no slideshows, books or calendars, for instance - but it should get all your albums and keywords back.
    Because this process creates an entirely new library and leaves your old one untouched, it is non-destructive, and if you're not happy with the results you can simply return to your old one. .
    Regards
    TD

  • I can't open my current photo library using this version of iPhoto

    This is the error I get when I click on upgrade after I installed Iphoto 09
    "You cant open your current photo library using this version of iphots, You have made changes to your photo library using a newer version of iPhoto. Please quit and use the latest version of iPhoto.
    Someone please help... I have a lot of photos and now I cant access them!!!

    Do you have and faces and places set? If not or not enough that it would not be an effort to redo, try using iPhoto Library Manager to rebuild the library as follows:
    Using iPhoto Library Manager to Rebuild Your iPhoto Library
    1 -Download iPhoto Library Manager and launch.
    2 -Click on the Add Library button, navigate to your User/Pictures folder and select your iPhoto Library folder.
    3 - Now that the library is listed in the left hand pane of iPLM, click on your library and go to the File->Rebuild Library menu option
    4 - In the next window name the new library and select the location you want it to be placed.
    5 - Click on the Create button.
    Note: This creates a new library based on the LIbraryData.xml file in the library and will recover Events, Albums, keywords, titles and comments but not books, calendars or slideshows. *The original library will be untouched for further attempts at fixing or in case the rebuilt library is not satisfactory.*

  • Equi Join and Outer join using outer keyword

    Hi,
    First lets take the create statment for scott schema.
    create table scott.emp_details(empno number, bonus_date date);
    Insert Into Scott.Emp_Details Values(7369, To_Date('01-jan-2013'));
    Insert Into Scott.Emp_Details Values(7499, To_Date('05-jan-2013'));
    Insert Into Scott.Emp_Details Values(7521, To_Date('10-jan-2013'));
    Insert Into Scott.Emp_Details Values(7566, To_Date('01-feb-2013'));
    Insert Into Scott.Emp_Details Values(7654, To_Date('05-feb-2013'));
    commit;lets also consider the basic scott.emp and scott.dept tables
    Now I would like to equi join emp table deptno col with dept table deptno col and left outer join emp table hiredate with emp_details bonus_date and empno col in emp_details can be joined(Equi Join) with empno col of emp table if needed .The outer join has to be placed using the keyword (left/right)outer join
    The select statement can have all the detials of emp table .The requirement may look weird but we have some such requirement.
    Please suggest

    Hi,
    sri wrote:
    Hi,
    First lets take the create statment for scott schema.
    create table scott.emp_details(empno number, bonus_date date);
    Insert Into Scott.Emp_Details Values(7369, To_Date('01-jan-2013'));
    Insert Into Scott.Emp_Details Values(7499, To_Date('05-jan-2013'));
    Insert Into Scott.Emp_Details Values(7521, To_Date('10-jan-2013'));
    Insert Into Scott.Emp_Details Values(7566, To_Date('01-feb-2013'));
    Insert Into Scott.Emp_Details Values(7654, To_Date('05-feb-2013'));
    commit;
    It's best not to create your own tables in Oracle-supplied schemas, such as SCOTT. Use your own schema for your own tables.
    lets also consider the basic scott.emp and scott.dept tablesI see; you're using the standard scott,emp and scott.dept tables, plus the emp_details table you posted above.
    Now I would like to equi join emp table deptno col with dept table deptno col and left outer join emp table hiredate with emp_details bonus_date and empno col in emp_details can be joined(Equi Join) with empno col of emp table if needed .The outer join has to be placed using the keyword (left/right)outer join
    The select statement can have all the detials of emp table .The requirement may look weird but we have some such requirement.
    Please suggestThanks for posting the sample data. Don't forget to post the exact output you want from that sample data.
    Do you want something like this?
    `    EMPNO ENAME          DEPTNO DNAME          BONUS_DAT
          7369 SMITH              20 RESEARCH       01-JAN-13
          7499 ALLEN              30 SALES          05-JAN-13
          7521 WARD               30 SALES          10-JAN-13
          7566 JONES              20 RESEARCH       01-FEB-13
          7654 MARTIN             30 SALES          05-FEB-13
          7698 BLAKE              30 SALES
          7782 CLARK              10 ACCOUNTING
          7788 SCOTT              20 RESEARCH
          7839 KING               10 ACCOUNTING
          7844 TURNER             30 SALES
          7876 ADAMS              20 RESEARCH
          7900 JAMES              30 SALES
          7902 FORD               20 RESEARCH
          7934 MILLER             10 ACCOUNTING
                                  40 OPERATIONSIf so, here's one way to do it:
    SELECT       e.empno, e.ename     -- or whatever columns you want
    ,       d.deptno, d.dname     -- or whatever columns you want
    ,       ed.bonus_date
    FROM           scott.dept  d
    LEFT OUTER JOIN      scott.emp   e   ON  e.deptno     = d.deptno
    LEFT OUTER JOIN      emp_details ed      ON  ed.empno     = e.empno
    ORDER BY  e.empno
    ;

  • Oracle deadlock - how to use "synchronised" keyword in a transaction?

    Hi,
    I use WL6.1 SP4, Oracle 8.1.6, with some Java objects which execute a
    lot
    of SQL queries (mixed update, insert and select) using plain JDBC
    calls,
    and Weblogic connection pools. These objects are called by servlets.
    I experienced recently deadlocks when two users call the object at the
    same
    time (See error below).
    I execute the queries using "synchronized" keyword in the following
    way:
    synchronized (this)
    conConnection.setAutoCommit(false);
    executeTransaction(myStatement);
    conConnection.commit();
    executeTransaction is overriden in sub-classes and is the method which
    executes
    all the queries.
    It calls methods in other objects. These methods are not declared as
    synchronized.
    1) Should they?
    2) Should I use the keyword "synchronized" in another way?
    3) This part of code is also called when I do only "select"
    statements. I guess
    it should only be synchronized when we do "update" and "insert" which
    could lead
    to a deadlock?
    4) Do you have any idea why this deadlock occurs as I use the
    "synchronized"
    keyword, and one thread should wait until the other one has finished?
    Thanks for any idea,
    Stéphanie
    ----------------- error:
    <ExecuteThread: '4' for queue: 'default'> <> <> <000000> <SQL request
    sent to database: UPDATE PARTICIPANT par SET par.PARTICIPANTLASTRANK =
    4 WHERE par.IDPARTICIPANT = 8983566>
    <ExecuteThread: '11' for queue: 'default'> <> <> <000000> <SQL request
    sent to database: UPDATE PARTICIPANT par SET par.PARTICIPANTLASTRANK =
    6 WHERE par.IDPARTICIPANT = 8983570>
    ORA-00060: deadlock detected while waiting for resource
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
         at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)
         at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:573)
         at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1891)
         at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:1093)
         at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:2047)
         at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:1940)
         at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2709)
         at oracle.jdbc.driver.OracleStatement.executeUpdate(OracleStatement.java:796)
         at weblogic.jdbc.pool.Statement.executeUpdate(Statement.java:872)
         at weblogic.jdbc.rmi.internal.StatementImpl.executeUpdate(StatementImpl.java:89)
         at weblogic.jdbc.rmi.SerialStatement.executeUpdate(SerialStatement.java:100)
         at bfinance.framework.EDBBLBean.executeSQL(EDBBLBean.java:299)

    Hi Stepanie,
    I'd try to group update statement together. Usually it helps.
    Regards,
    Slava Imeshev
    "Stephanie" <[email protected]> wrote in message
    news:[email protected]...
    Thanks for your answer.
    In the case you describe, is there a way to ensure that tx-2 waits for
    tx-1
    to be finished before beginning?
    My transaction which causes the problem is the following (simplified):
    UPDATE tableA SET islast=0 WHERE externalid=myid;
    for (int i=0; i< aVector.size(); i++) {
    INSERT INTO tableA (id, islast, ranking, externalid) (SELECT
    SEQ_tableA.nextval, 1, 0, myid);
    UPDATE tableA SET ranking = /*calculated ranking */
    WHERE externalid=myid AND islast=1;
    UPDATE tableB ....
    commit;
    tx-1 and tx-2 execute this transaction at the same time. tx-1 begins
    The deadlock appears when tx-2 executes the second UPDATE tableA
    query.
    I don't see how I can avoid to execute these two update queries, so if
    I can find another way to prevent deadlock, it would be great!
    Stéphanie
    Joseph Weinstein <[email protected]_this> wrote in message
    news:<[email protected]_this>...
    Stephanie wrote:
    Hi,
    I use WL6.1 SP4, Oracle 8.1.6, with some Java objects which execute a
    lot
    of SQL queries (mixed update, insert and select) using plain JDBC
    calls,
    and Weblogic connection pools. These objects are called by servlets.
    I experienced recently deadlocks when two users call the object at the
    same
    time (See error below).Hi. The error you are getting isn't necessarily from a lack ofsynchronization
    of your java objects. It has to do with the order in which you accessDBMS
    data. You are getting ordinary DBMS deadlocks, which are caused when
    two DBMS connections each have a lock the other wants, in order toproceed.
    The DBMS will quickly discover this and will kill one transaction inorder to
    let the other one proceed:
    time 0: tx-1 and tx-2 have started.....
    time 1: tx-1: update tableA set val = 1 where key = 'A'
    time 2: tx-2: update tableB set val = 2 where key = 'B'
    time 3: tx-1: update tableB set val = 1 where key = 'B' (waitsbecause tx-2 has the row
    locked)
    time 4: tx-2: update tableA set val = 2 where key = 'A' (waitsbecause tx-1 has the row
    locked)
    This is a deadlock. The solution is to organize your application code sothat every
    transaction accesses the data in the same order, eg: update tableAfirst, then update tableB.
    This will prevent deadlocks.
    Joe Weinstein at BEA
    I execute the queries using "synchronized" keyword in the following
    way:
    synchronized (this)
    conConnection.setAutoCommit(false);
    executeTransaction(myStatement);
    conConnection.commit();
    executeTransaction is overriden in sub-classes and is the method which
    executes
    all the queries.
    It calls methods in other objects. These methods are not declared as
    synchronized.
    1) Should they?
    2) Should I use the keyword "synchronized" in another way?
    3) This part of code is also called when I do only "select"
    statements. I guess
    it should only be synchronized when we do "update" and "insert" which
    could lead
    to a deadlock?
    4) Do you have any idea why this deadlock occurs as I use the
    "synchronized"
    keyword, and one thread should wait until the other one has finished?
    Thanks for any idea,
    Stéphanie
    ----------------- error:
    <ExecuteThread: '4' for queue: 'default'> <> <> <000000> <SQL request
    sent to database: UPDATE PARTICIPANT par SET par.PARTICIPANTLASTRANK =
    4 WHERE par.IDPARTICIPANT = 8983566>
    <ExecuteThread: '11' for queue: 'default'> <> <> <000000> <SQL request
    sent to database: UPDATE PARTICIPANT par SET par.PARTICIPANTLASTRANK =
    6 WHERE par.IDPARTICIPANT = 8983570>
    ORA-00060: deadlock detected while waiting for resource
    at
    oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
    at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)
    at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:573)
    atoracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1891)
    atoracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:1093)
    atoracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:2047
    atoracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:1940)
    atoracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java
    :2709)
    atoracle.jdbc.driver.OracleStatement.executeUpdate(OracleStatement.java:796)
    atweblogic.jdbc.pool.Statement.executeUpdate(Statement.java:872)
    atweblogic.jdbc.rmi.internal.StatementImpl.executeUpdate(StatementImpl.java:89
    atweblogic.jdbc.rmi.SerialStatement.executeUpdate(SerialStatement.java:100)
    at bfinance.framework.EDBBLBean.executeSQL(EDBBLBean.java:299)

  • Use 'default' keyword in call string while calling stored proc?

    I am calling following sql server stored procedure from java code using my jdbc driver for sql server: CREATE PROCEDURE test_findTbInfo (
    @paramIn_Str varchar(10),
    @paramOut_Int int OUT,
    @paramIn_Int int = 20
    AS
    begin
    set @paramOut_Int = @paramIn_Int * 100
    end
    If I make a call like this:
    CallableStatement cs = conn.prepareCall(" { call test_findTbInfo(? , , ? ) }");
    cs.setString(1, "test_tab");
    cs.setInt(2, 4);
    cs.execute();
    It works without any error. But this is not a right behavior. !! The second parameter as you see is passed like an optional parameter. But in stored proc it is NOT an optional param and so if the value not passed it should fail...
    Now if I change the code to
    CallableStatement cs = conn.prepareCall(" { call test_findTbInfo(? , default, ? ) }");
    it works correctly. Gives error that "Procedure 'test_findTbInfo' expects parameter '@paramOut_Int', which was not supplied." which is correct.
    So is it a normal practice to use 'default' keyword while calling sql server stored procedures having optional parameters in jdbc ????
    Anyone knows ??? As far as I know "call test_findTbInfo(? , , ? )" works fine except in some cases and also it forces users to put all optional parameters at the end of parameter list in stored proc.
    Please let me know whether I should go with 'default' throuout for sql server stored proc while calling using my jdbc driver.
    Amit

    {?= call <procedure-name>[<arg1>,<arg2>, ...]}The question mark in the above is the result parameter
    that must be registered.
    That is not the same as an OUT argument.Yes that is true. The result value and OUT parameters are different but they both MUST be registered as per jdbc API
    "The type of all OUT parameters must be registered prior to executing the stored procedure; their values are retrieved after execution via the get methods provided here."
    Anyway, my original question still stays as it was. If there are some optional IN parameters in stored procedure
    e.g.
    PROCEDURE test_findTbInfo (
    @paramIn_Int int = 20,
    @paramOut_Int int OUT
    how do you call this?
    CallableStatement cs = conn.prepareCall(" { call test_findTbInfo( , ? ) }");
    cs.registerOutParameter(1, Types.INTEGER);
    cs.execute();
    or
    CallableStatement cs = conn.prepareCall(" { call test_findTbInfo(default, ? ) }");
    Also note that I am intending to use ONLY sql server driver for this.
    The first as well second seem to work. Except that second way is seems reliable. I just wanted a second opinion on that...
    Amit

  • Can i use this dbms_system.ksdwrt package to purge my table

    I have used this package to purge sys.Aud$ table.
    My question is can i use this same package to purge my ordinary database table
    which is not owned by sys or system but any of DB schema.
    i.e Torrent.tbl_pm_read_torrent.
    .

    I have used this package to purge sys.Aud$ table.
    My question is can i use this same package to purge
    my ordinary database table
    which is not owned by sys or system but any of DB
    schema.
    i.e Torrent.tbl_pm_read_torrent.Your question is unclear!
    dbms_system.ksdwrt allows writing to either a trace file or the alert.log. It doesn't per se have anything to do with purging the audit log. So given that we don't know what you did in the first place offering an answer is going to be difficult.
    for purging in general though, I've found that the designers of the sql languiage considered this use case and gave us a keyword beginning with 'D' that proves handy.
    Niall Litchfield
    http://www.orawin.info/

  • How to Use native keyword in java programming

    Hi ,
    I am using JDK 1.6.0_11 , and i was trying to create a java program using "native" keyword ,
    i got the sample code for the same from the site : - http://www.javaworld.com/javaworld/javatips/jw-javatip23.html
    But when i type this command " C:\javah -stubs Happy " following error occurs
    " Error: JNI does not require stubs, please refer to the JNI documentation. "
    then typed " c:\javah -jni Happy" without any error .
    After that i wrote a HappyImpl.c as mentioned in the above tutorial
    #include <StubPreamble.h> /* Standard native method stuff. */
    #include "Happy.h" /* Generated earlier. */
    #include &ltstdio.h> /* Standard C IO stuff. */
    void Happy_printText (struct HHappy *this)
    puts ("Happy New Year!!!");
    then it is not compling and error is
    "unable to open included file StubPreamble.h file
    unable to open included file Happy.h file "
    Please help me . i want to use native method , i did exactly the same in tutorial at above link.
    Thanks & Regards
    Mannat

    you do need to know how to use your C compiler... It quite clearly can't find those files which indicates that you didn't tell it where to find them.

Maybe you are looking for

  • HP laserjet p1102w firmware update problem

    HP offers an update of firmware for Eprint, nevertheless this update has a mistake since when it establishes himself and got the power off the printer, the IP gets lost in the memory of the printer and changes for 0.0.0.0. It is a mistake for HP in t

  • Generate a row id

    Hi Guys, I would like to generate a row id in a column as I'm inserting records into a table. Any ideas? sequences is good approach? Thank you

  • Ipod flipping through songs

    My ipod is going crazy...when I turn it on and pick a song or playlist it starts flipping through all of my songs or all of the songs on the playlist until it gets to the end and then goes back to the main menu...it will not let me play a song at all

  • HIERARCHIES ON QUERY DESIGNER

    Hi Guys! I have a 0ITEM hierarchy with 8 levels, i need to display only from level 4 to level 8 on query designer 7.1, can somebody help me with this? Thanx and Regards

  • Work Order and Notification

    Hello, am a bit new with PM process, can anyone tell me how to do a work order with notification on it and confirmation will be made to the work order? please guide me step by step which is first to do and the transaction for each? thanks