How to avoid mutation on database tables

Posted in General, java, oracle on September 5th, 2012 by admin – Be the first to comment

What is mutation ?

Clear definition here – http://www.databasejournal.com/features/oracle/article.php/3329121/The-Mutation-error-in-Oracle-Database-Triggers.htm

When will you come across mutation?

In practice, you will come across mutation problems when you are trying to modify a table in the database while that same table is getting updated by another process.

A typical scenario

Think of sort in a table. You let the client modify the sort order for each entry on a table. To accomplish this, you will create a trigger on update, that takes the new sort value of the row that was modified and changes the entries before and after accordingly. So if you have 10 employees, each with incremental sort orders from 1 to 10, changing number 6 to number 7 will perform the following logic.

– Find the employee with a sort order of 7, change it to 6.

Notice that during this operation, you will have to update the same table inside the update trigger. This is a classic Oracle mutation issue. Usually you will get a

ORA-04091: table TRANSACTIONS is mutating, trigger/function may not see it

 

Solution

When you research online, you will find a variety of solution. Asktom’s solution will suggest that you create a custom view based on that table, and then create a trigger on that view which updates the original table. This didn’t really work for us.

Some other solutions also mentioned creating a new package etc.

What works perfectly is inside the trigger, create an autonomous context in the code. This tells oracle to  consider the chunk of code that is inside the autonomous context annotation to work in a new session from the rest of the procedure.

Consider the following for example,

CREATE OR REPLACE TRIGGER TRG_UPDATE
AFTER UPDATE ON TABLEX
FOR EACH ROW
DECLARE
PRAGMA AUTONOMOUS_TRANSACTION; — This is where the magic happens
BEGIN

UPDATE TABLEX …
COMMIT;

END TRIGGER TRG_UPDATE;

Related Links and Solutions

 

http://docs.oracle.com/cd/B14117_01/appdev.101/b10807/13_elems002.htm

 

 

Maven kickstart with a practical example

Posted in General on August 6th, 2012 by admin – Be the first to comment

Maven

WHAT :  A software project management tool that can automate the build and many other build related processes.

WHY: Store all your project dependencies, document your process of  “building” onto an XML file. Think about a more visual ant. btw, Maven can generate ant scripts, which you can use for building.\

KICKER: It can download jar files from repositories, depending on what you may need. Imagine this capability when taking over an existing project.

MORE: Maven has a lot of plugins, which we can leverage just by setting up the project as a Maven project. Lets try to do a small project that will really show you the real advantage of Maven

 

Project: Generate a Java object /Bean from a json file. Use Maven.

This will generally be used when you trying to write a wrapper for all sorts of REST API and all, for example; Basecamp

Step 1: Lets look at Basecamp’s API

Step 2: We want to generate the object for the API endpoint Project

Step 3: Here is  a sample JSON


Step 4: Lets generate an XML from the JSON using this online converter 

Step 5: Now we have an XML, lets also get the XSD ( definition) using this link, we can use our XML file generated in step 4.

Step 6: Install Maven in your computer.

Step 7: Set your classpath to point to the directory where you unzipped it {install_directory}/maven/bin should the value of your classpath.

Step 8: See if the classpath setting worked by typing mvn on the command prompt/shell etc

Step 9: Lets create a skeleton project using maven. execute this command

mvn archetype:generate -DgroupId=com.mycompany.app -Dar
tifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMo
de=false

Step 9:  Check out the folder, you should have a directory called my-app in there. Look for a file called pom.xml. This is what stores all the dependency. This is also the place where you should tell maven to download different plugins.

Step 10: We will be using the JAXB plugin, this can take an XSD file and generate a corresponding Java Object.

Step 11: Open up pom.xml, and add the dependency as explained on this document

Step 12: Once everything is ready to go, open up the my-app folder, to the location described below, and create a file called “Project.xsd”

Step 13: Go to command prompt/shell , browse to my-app, and run mvn compile. This in essence, will do everything for you, it is configured to look under the folder for xsd files, download the necessary jar files for JAXB, and run the code generation. Once everything is done, take a look at the my-app folder for generated sources

Step 14: As Maven is a complete software generation project management system, there are very many “pretty-up” features. Try out the commands mvn site, mvn clean, mvn install, mvn package  etc. They are all very helpful

 

 

 

 

Weblogic Server: How to make sure the JSP’s refresh on weblogic

Posted in General on May 8th, 2012 by admin – Be the first to comment

I couldn’t get my head around this problem for a very long time. Basically there is are xml files that tells weblogic what to do in a global level, and then you can specify in application level as well.

All you have to do is find the weblogic.xml file ( if your application has one, then that is the one to change)

and look/add/modify the file so it has the following

   <jsp-descriptor>
      <jsp-param>
         <param-name>keepgenerated</param-name>
         <param-value>true</param-value>
      </jsp-param>
      <jsp-param>
         <param-name>pageCheckSeconds</param-name>
         <param-value>0</param-value>
         <verbose>true</verbose>
		 <precompile>false</precompile>
      </jsp-param>
   </jsp-descriptor>

  • Keepgenerated -> Tells weblogic to keep the java class files for easy debugging
  • pageCheckSecond -> if its -1, weblogic will not refresh jsps. so we set it to 0.
  • verbose: lets you see debug messages in the application
  • Precompile: Does not precompile the jsp
Make sure you are aware that this is basically intended during development. You really do not want to do this in produciton. Also check if your server is running in production mode
Here is a detailed description of the weblogic.xml jsp parameters

 

What is a web apps end to end testing

Posted in General on April 27th, 2011 by admin – Be the first to comment

After all the development is done and the features have been crossed off the functional document as “Complete”, how do you conduct an “end-to-end” test to make sure the application is sane and should be given to a client. Here is my list for any given web application.

1. No Flow error ( the application doesnt stop anywhere because of a bug)
2. Fonts/colors/ and text throughout the application is consistent ( there is no accidental bold or different font anywhere)
3. All the validation errors on the forms are graceful and shows the errors nicely.
4. There are no spelling mistakes any where on the application.
5. The form designs are nicely aligned and looks good to the eyes.

Top Cross platform mobile development tool

Posted in General, Mobile on December 22nd, 2010 by admin – Be the first to comment

For a while now, we have been searching for the perfect development platform for development on mobile devices. Did we find it? The answer is probably ….”Still Searching”. But we came across some really neat tools that we wouldn’t mind sharing with developers and some of our clients.

Essentially what you need to figure out is what do you intend to accomplish during your development. Simply speaking, there could only be three things

  1. Its a background process on the phone ( like intercept SMS or Start a call)
  2. Its a hybrid app ( such as something that access the contact book on the phone, as well as the web), also known as mobile-web sometimes.
  3. Its a complete web application, just runs on mobile

Now for our development purposes, #2 and #3 is most realistic, although there are some cases where we have to touch #1. For the purpose of this article, we will leave out #1. But a lot of the solutions that we will introduce on this article,  also takes care of a subset of core phone apps as in #1. Here are some of the best apps for iphone.

Ok so here are our research results

RhoMobile

Phonegap

Appcelerator

Mosync

Android Application development Basics

Posted in General, Mobile on December 22nd, 2010 by admin – 2 Comments

Fantastic! You have finally decided to jump into android development. Let’s face it, with the growth of droid devices and predictions of where it will be in the next couple of years and with google’s new announcements such as googletv, it is the perfect time to start off.

We have started on the same journey and as we go along, we will post tips and tricks that we have found useful. There are numerous articles online with detailed instructions on the “how to”s, but there is a lack of comprehensive lists, or index of tutorials if you will, to let developers know how they should dive deep into android development. Hence we decided to write this article in such a way that it will sort of serve a study plan for to-be android developers as well.

Prerequisites

  1. You are  a Java developer or you are very familiar with Java
  2. You know how to use the eclipse IDE

Setup instructions

  1. Get the android SDK
  2. Add android to your path
  3. Add software on Eclipse IDE
  4. Run the AVD ( Android Virtual Device) with some sample application to get a feel of it

Developer’s Notes

  1. Check out the application framework
  2. Memorize the following set of services that you can use in your application
    • Views ( All UIs, like buttons,grids)
    • Content providers ( Access the phone, like contacts)
    • Resource Managers (Provide access not non-code elements such as graphics fonts etc and things under the res/ folder )
    • Notification Managers (Used to create custom alerts that can pop up)
    • Activity Managers (  By definition: “An activity is a single, focused thing that the user can do”. This is what the user sees)
  3. There is no main() method. The application starts by loading components, namely
    • Activity ( Think of it as a screen that has views. In the WAP world, this will be similar to a “deck”)
    • Broadcast Receivers ( Receive and react to the notification manager)
    • Cotent providers ( Makes data available to other applications)
    • Services ( runs in the background and actually does the job)
  4. An example to put things in perspective
    An mp3 player applications has a list of songs, drawn by the Activity, The file list is retrieved by a service and the music is actually played by a service as well. While the music is playing a broadcast receiver can pop up a message saying the battery is low, while a content provider tells another application which song is currently being played so that it can tweet it
  5. The components are all defined on the Manifest file

Once you have finished reading this far, and all the related articles. Do the complete Notepad exercise

Getting Wifi Tether on your motorola backflip

Posted in Mobile on December 7th, 2010 by admin – Be the first to comment

Ok So I have checked hundreds of tutorials online regarding this, but after much experiment, The following is the best way to root your Motorola Backflip (MB 300) and get Wi-Fi tether on it. Why would we “root”? to use an ipod touch with my android on nearby

Have the following things handy

  1. Motorola device driver http://modmymobile.com/forums/downloads.php?do=file&id=28159
  2. connectbot for shell access to your device http://code.google.com/p/connectbot/
  3. Install adb here http://developer.android.com/sdk/index.html

Ok so to root it follow this tutorial

http://modmymobile.com/forums/567-motorola-backflip-general/555749-root-all-versions-backflip.html

Once you are done rooting, install the wifi tether from here

http://code.google.com/p/android-wifi-tether/downloads/list

if the Wi-fi tether doesnt work, try barnacle , this definitely works

http://szym.net/projects/index.html

Neat little drupal plugin for Mail handling

Posted in General on June 23rd, 2010 by admin – Be the first to comment

This is a nice roundup tutorial including a screencast on how to configure mailhandler for your Drupal Installation. It can pull emails from multiple accounts and you can configure it to end up as different content types on drupal. End result? Email a picture and make it show up as gallery item OR email a video and make it show up as a flowplayer item.
check it out !
Drupal Mimerouter Tutorial

Hotgloo has launched

Posted in General on March 4th, 2010 by admin – Be the first to comment

We have been internally using this wireframing tool for a while now and it has gone live now! Every designer and deveveloper should take a lot at this baby as it boasts a flash interface, collaboration, usability and fast prototyping.

Everything works pretty smoothly when you start wireframing, unlike a lot of the web based ones. We are using aviary toolbars to connect it to basecamp. Planning to write an API call to stream data directly.

Symbian OS has finally gone open source

Posted in General on February 26th, 2010 by admin – Comments Off on Symbian OS has finally gone open source

Although it’s the most popular mobile OS, powering some 330 million phones, Symbian has been in limbo lately. On one side, it competed against the increasingly popular (and completely closed) iPhone, while many manufacturers, such as Motorola, opted to use the open source Android, which offers a much more similar experience to iPhone than most Symbian phones.

http://mashable.com/2010/02/04/symbian-open-source/