Himu\’s Attempt at Blogging

Tidbits from my thoughts

2012 in review

leave a comment »

The WordPress.com stats helper monkeys prepared a 2012 annual report for this blog.

Here’s an excerpt:

4,329 films were submitted to the 2012 Cannes Film Festival. This blog had 56,000 views in 2012. If each view were a film, this blog would power 13 Film Festivals

Click here to see the complete report.

Written by mhimu

December 31, 2012 at 12:20 pm

Posted in Uncategorized

Multiple Choices in Spring Injection – @Resource, @Autowired and @Inject

leave a comment »

I just came up with this wonderful blog post by David Kessler. Kudos David!

Spring Injection with @Resource, @Autowired and @Inject.

Written by mhimu

April 5, 2012 at 1:35 pm

Posted in Java, spring

Tagged with , , ,

Oracle 11g EM & Password Expiry

with one comment

I’ve faced this issue twice now – passwords expired after a certain time by default in Oracle 11g. But this also messes up EM (dbconsole) by locking up SYSMAN (status shown as LOCKED(TIMED)). The following link has the details on how to deal with change of password of SYSMAN and DBSNMP in Enterprise Manager: https://forums.oracle.com/forums/thread.jspa?threadID=1011436

In short:

  1. Reset password and unlock SYSMAN
    1. sqlplus /nolog
    2. conn / as sysdba
    3. alter user sysman identified by <pass>
    4. alter user sysman account unlock
  2. Make EM pick up the change
    1. emctl stop dbconsole
    2. emctl setpasswd dbconsole
    3. emctl secure dbconsole
    4. emctl start dbconsole
  3. Fireup EM and log on using SYS as SYSDBA
    1. EM will ask to change all expired/soon-to-be-expired passwords
  4. For DBSNMP please see the given link above

Written by mhimu

February 6, 2012 at 5:03 pm

Posted in Uncategorized

Spring MVC Error Handling

leave a comment »

This is not a tutorial of any sort. I’m adding this post to record the error-handling techniques of Spring MVC.

Catching

Errors can be caught in two places:

  1. Inside a validator (extended from Validator)
  2. Inside a controller

1. Validator

In the validate() overridden method, we can use two approaches:

a) Using the errors object:

errors.rejectValue(field, code, defaultMessage) → for field errors
errors.reject(code, defaultMessage)  → for global/general errors

b) Using ValidationUtils.rejectXxx(…) methods

2. Controller

In the onSubmit(request, response, command, BindException errors) overridden method:

errors.rejectValue(field, code, defaultMessage) → for field errors
errors.reject(code, defaultMessage)  → for global/general errors

return new ModelAndView(getFormView(), errors.getModel())

getFormView() returns us to the input form. The call to errors.getModel() is crucial here.

Reporting with JSP

<form:form command=”commandNameIfChangeFromDefault”>
<span class=”…”>
<spring:hasBindErrors name=”command”>
<c:forEach items=”${errors.allErrors} var=”error”> <!– or errors.globalErrors or errors.fieldErrors –>
<spring:message code=”${error.code}” text=”${error.defaultMessage}”/>
</c:forEach>
</spring:hasBindErrors>
</span>
</form:form>

Written by mhimu

September 27, 2010 at 3:41 pm

Posted in Java, spring

Spring MVC Tutorial – Using Tiles 2

with 7 comments

This post is also based on my previous work:

  1. Spring MVC Tutorial – Hibernate Integration – build a Spring MVC app using Hibernate from the ground up.
  2. Spring MVC Tutorial – Paging through Hibernate and Selection Handling – add table/list browsing support utilizing paging in Hibernate, add a page navigation bar, add checkbox handling against table rows.

Here I will not add any new functionality – just move the view technology to Tiles 2 that comes bundled with Spring complete distribution.

The new completed project is available as ibank-v3.zip.

Till now, I have repeated header/footer/menu code in all the JSP files. Tiles 2 can be used to remove that repetition. Let’s begin.

Read the rest of this entry »

Written by mhimu

December 9, 2009 at 2:53 pm

Posted in Java, spring

Tagged with , , ,

Spring MVC Tutorial – Paging Through Hibernate and Selection Handling

with 14 comments

In this installment, I’m expanding the project done in Spring MVC Tutorial – Hibernate Integration to include:

  1. Browsing/paging through a table with a navigation bar found in various forum sites and ASP.NET GridView (e.g. First 3 4 5 6 7 Last)
  2. Showing checkboxes against each row of the table for selective action

The related project code download is ibank-v2.zip

Read the rest of this entry »

Written by mhimu

November 26, 2009 at 3:31 pm

Spring MVC Tutorial – Hibernate Integration

with 43 comments

After a long gap…

For introduction to Spring MVC in particular, see Spring MVC Tutorial and Spring MVC Tutorial 2.

The project done in STS can be downloaded from my Box.net account. The project libraries you will have to edit to match your setup.

Along with learning to integrate Hibernate, I’ll be introducing some new pieces of Spring MVC.
Read the rest of this entry »

Written by mhimu

November 16, 2009 at 2:44 pm

Posted in Java, spring

Tagged with , , ,

SQL – Dynamic Date Range, Number Range in Oracle, SQL Server, and DB2/400

with 9 comments

Often, we need to make coverage reports that span over a period of time and where all points in the period do not contain data.

Assume a shop has 50 outlets and we want to find the number of sales in each branch over the past ten days. Business is bad in some areas and so some outlets had no sale at all. A query like the following will give only those outlets that had sales but not a list of all outlets:

SELECT outletid, saledate, count(*)
FROM sales
GROUP BY outletid, saledate
ORDER BY outletid, saledate

Read the rest of this entry »

Written by mhimu

May 7, 2009 at 11:03 am

ODI – Incremental Update and Surrogate Key using Database Sequence

with 17 comments

I am writing this because it had me lose my sanity for some time. If,

  • You’re using Oracle Data Integrator
  • You’ve defined a dimension table with a surrogate key even if it is not a SCD type 2 (recommended by Kimball)
  • The surrogate key is maintained through a database sequence (Oracle sequence in my case)
  • Your IKM in Incremental Update
  • You’re frustrated about how to control updates to a dimension having a sequenced surrogate key

Then read on for the solution that worked for me. The solution is pretty standard – you only need to know what you’re doing and setting the right options.

Read the rest of this entry »

Written by mhimu

May 4, 2009 at 4:35 pm

ODI – How to Reverse Flat Files

with 12 comments

The most important thing to remember before using flat files as datastores in ODI is that the Designer looks for them in the client PC where it runs. I haven’t tried using a UNC (\\computer\share\…) but that should work.

ODI comes pre-configured with a folder for dealing with flat files – in the Topology Manger, you’ll find the FILE_GENERIC data server set up to serve files from the ODI_HOME/oracledi/demo/file directory. But if you want your own file data server then follow these steps:

Read the rest of this entry »

Written by mhimu

May 1, 2009 at 3:15 pm