Posts

Identify cursor leak in Oracle

As a developer it is important to know which Oracle cursor is not being closed or reused on each execution that leads to the following Oracle error: "ORA-01000: maximum open cursors exceeded." We can identify these type of leaks by using some tools but this is a bit hectic to identify in code level. So the solution is we can diagnose these from oracle database side with a minimal queries... 1. Identify the session by its Oracle username to retrieve the sid value. SQL> SELECT sid FROM v$session WHERE username = 'BRAHMA'; sid ----------- 1234 2. List the session's SQL statement addresses, which have more than one active reference. Using the sid value from the previous statement, execute a query against the v$open_cursor view. SQL> SELECT COUNT(*), address FROM v$open_cursor WHERE sid = 1234 GROUP BY address HAVING COUNT(address) > 1 ORDER BY COUNT(*); COUNT(*) ADDRESS ---------------- ---------------- 2 35E6083C 2 ...

Cache using @Cacheable annotation in Spring itself......

Spring 3.1 Provides Cache using @Cacheable annotation.. Methods for whom the result is stored into the cache so on subsequent invocations (with the same arguments), the value in the cache is returned without having to actually execute the method. In its simplest form, the annotation declaration requires the name of the cache associated with the annotated method: @Cacheable("books") public Book findBook(ISBN isbn) {...} Just like other services in the Spring Framework, the caching service is an abstraction (not a cache implementation) and requires the use of an actual storage to store the cache data - that is, the abstraction frees the developer from having to write the caching logic but does not provide the actual stores. This abstraction is materialized by the  org.springframework.cache.Cache  and  org.springframework.cache.CacheManager  interfaces. There are  a few implementations  of that abstraction available out of the box: JDK ...

Spring MVC Flow

Image
Spring MVC Flow is as follows: ----------------------------------------------------------------- The Dispatcher Servlet is heart of the Spring MVC and it involves in all the phases of the process. Step 1: First request will be received by DispatcherServlet. Step 2: DispatcherServlet will take the help of HandlerMapping and get to know the Controller class name associated with the given request. Step 3: So request transfer to the Controller, and then controller will process the request by executing appropriate methods and returns ModeAndView object (contains Model data and View name) back to the DispatcherServlet. Step 4: Now DispatcherServlet send the model object to the ViewResolver to get the actual view page. Step 5: Finally DispatcherServlet will pass the Model object to the View page to display the result. That’s it

Runtime Polymorphism in java

Runtime Polymorphism: -------------------------------------------------- --------------------------------------------------- Polymorphism is the foundation of Object Oriented Programming. It means that one object can be have as another project. So how does on object can become other, its possible through following Inheritance Overriding/Implementing parent Class behavior Runtime Object binding One of the main advantage of it is switch implementations. Lets say you are coding an application which needs to talk to a database. And you happen to define a class which does this database operation for you and its expected to do certain operations such as Add, Delete, Modify. You know that database can be implemented in many ways, it could be talking to file system or a RDBM server such as MySQL etc. So you as programmer, would define an interface that you could use, such as...public interface DBOperation { public void addEmployee(Employee newEmployee); public void modifyEmployee(int id, Em...

A Brief Description about Web Services

Web Services: --------------------------- Why we need to go with Webservices? A: WebServices is one of the Distributed Technology like EJB and RMI. Problem with EJB and RMI: ------------------------- -->Language Dependent -->Robust -->Heavy Weight Benefits with WS: --------------------- WS is Interoperable which means Language Independent and Platform Independent and provide Enterprise services like other technologies EJB and RMI. WS flow: ------------ For Example what we need for communication b/w two persons? like we need --> Two persons --> Medium --> Language --> Rules (protocol). like that if two applications need to communicate we need --> Consumer : which consumes(using) the services --> Provider : Service provider --> protocaol : HTTP, FTP and SMTP. ( In internat world we prefer HTTP) --> Language : XML --> Medium : both applications should be connected (network). So the final conclusion is: "The Consumer will send XML to co...

Dispatcher Servlet Configuration in Spring and log4j Configuratin

Log4J : --------------- log4j.properties log4j.rootLogger=ERROR,console #Console Appender  log4j.appender.console=org.apache.log4j.ConsoleAppender log4j.appender.console.layout=org.apache.log4j.PatternLayout log4j.appender.console.layout.ConversionPattern=[%5p] [%t %d{hh:mm:ss}] (%F:%M:%L) %m%n #Custom assignments log4j.logger.controller=DEBUG,console log4j.logger.service=DEBUG,console log4j.logger.dao=DEBUG,console #Disable additivity log4j.additivity.controller=false log4j.additivity.service=false log4j.additivity.dao=false web.xml: -------------------- we can configure Dispatcher Servlet and context config location like as follows <?xml version="1.0" encoding="UTF-8"?> <web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee ht...

Spring - Hibernate Integration Jars with Maven(POM)

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">   <modelVersion>4.0.0</modelVersion>   <groupId>org.krams.tutorial</groupId>   <artifactId>spring-hibernate-mysql</artifactId>   <packaging>war</packaging>   <version>1.0.0-SNAPSHOT</version>   <name>spring-hibernate-mysql Maven Webapp</name>   <url>http://maven.apache.org</url>   <dependencies>   <dependency>   <groupId>junit</groupId>   <artifactId>junit</artifactId>   <version>4.8.1</version>   <type>jar</type>   <scope>compile</scope>   </dependency>   <dependency>     <groupId>org...