Tuesday, July 10, 2012

DataBase Export using Jdeveloper


I have been using Jdeveloper for years now and still was not aware of this cool utility.
Most of the time we need to take backup of our custom Schema/Database , Jdeveloper provides a very simple tool to do this.

Steps:

1. Tools | Database Export

2. Choose the connection and File location for the SQL script for export



3. Choose the object types you want to export



4. Select the Objects , it lists all the eligible objects (Tables , Sequences,constraints ,etc )


5. Specify the data, yes you got it right it exports table data as well


6. Validate summary and Finish

That's it , you will get a SQL script properly commented with DDL and DML for all the objects.

Its cool !!


Thursday, June 21, 2012

Override EntityImpl Lock


One of the common exception that we face in ADF is :
" JBO-26030: Failed to lock the record, another user holds the lock "
A lot has been written and explained about this , In a simple implementation below is how i resolved this by overriding the lock () method in EntityImpl

Tries 3 times after  a gap of 10 sec for trying to get the lock.

        while ((++tries <= 3) && !islock)
        {
          try
          { super.lock();  islock = true; }
             catch (AlreadyLockedException a)
             { try
                { Thread.sleep(10000); }catch (InterruptedException e){e.printStackTrace();}
                }catch(RowInconsistentException e){
                refresh(REFRESH_WITH_DB_ONLY_IF_UNCHANGED|REFRESH_CONTAINEES);
            }
         }
   
        if (!islock)  throw new AlreadyLockedException(new Exception());

More explanation can be found at :
https://blogs.oracle.com/onesizedoesntfitall/entry/the_case_of_the_phantom