Showing posts with label Java. Show all posts
Showing posts with label Java. Show all posts

Saturday, January 12, 2013

Data Access With Spring JDBC (Note 1)

When developing enterprise applications, we have lots of options when it comes to the implementation of the DAO (Data access Object) layer. Either we may use an ORM framework like Hibernate, iBatis or pure JDBC. 

JDBC fulfills almost all the necessary data access requirements. and provides low level access to the data access operations. But we have to handle connections and lots of other things. 

Friday, January 11, 2013

Playnig With HTTP Methods

I am highly interested in RESTful web services these days :) . So I tried to implement my own RESTful API and wrote REST client to communicate with the service. GET, POST, PUT, DELETE are basic HTTP methods used in REST services (details of HTTP methods can be found here) . Lets see how I implemented basic CRUD operations using HTTP methods.

For the sake of simplicity I have simply echoed the request body and selected request headers back as the service implementation.

Monday, December 17, 2012

Using SQLite with JDBC

I had to implement an application which should utilize a portable database. For better portability the application was implemented in java. As my first choice I selected several flat files for storing data in a hierarchical manner .

At the run time of the application , read operations were much higher than the write operations. It took minutes for traversing and search through each file on a search operation.

Considering all above facts I selected "SQLite" for storing and managing data in my application. Though it was bit slow while feeding data to the application , it was pretty fast when reading data from the database.

Tuesday, May 29, 2012

XML Serialization With XStream

XML Serialization is essential in some situations. Most probably we may use XML serialization when we need higher level of portability. XStream is a great library for xml serialization.
Serializing

Friday, April 20, 2012

Browser Automation With Selenium

Selenium is a browser automation framework. it is available in many flavors such as Java , .net , python . I am interested in Java implementation of Selenium.  Selenium can be successfully used in regression automation. It provides all the necessary functionalists required to automate the browser. Such as navigating, verifying, drag and drop,  clicking , selecting..etc.

Selenium can be downloaded from here
Getting started guide

Tuesday, April 3, 2012

Log4j In Action

Logging is very important for the maintenance of  a deployed application. Just assume a situation that we deploy our application on the client systems and work on another project. After some time client reports a failure of our system. What will happen if we haven't maintained a log file! We may be in a big trouble in such situations. It may be very hard to track where the bug occurred. Because we haven't any IDE's , debuggers on deployed machine.

So it is always recommended to use a logging mechanism for large applications. Logging may be a overhead if we don't use it carefully. We can use logging inside exception handling blocks.

Monday, April 2, 2012

Dependancy Injection (Spring Note 1)

Just assume a situation where we have to develop a module that must generate different types of reports such as PDF reports, Excel reports. One of a worst design for such scenario is design classes for each report separately without any form of polymorphism. Such a design may may result in increasing coupling of the program.
example :
ExcelReport excelReport=new ExcelReport();
PDFReport pdfReport=new PDFReport();

excelReport.initialize();
excelReport.createReport();
excelReport.saveReport();

pdfReport.initialize();
pdfReport.createReport();
pdfReport.saveReport();

Monday, March 26, 2012

JDBC Transactions

Most of the times transactions are important when we deal with JDBC. When we perform database operations if we don't realize the importance of transactions it will end up with a tragedy. I have created a scenario to demonstrate the importance of a transaction.
Scenario :
Lets assume a scenario where a transaction credit 500 rs from user1 and debit that 500 rs to user2 .

initial state of accounts

Thursday, March 22, 2012

Saturday, December 31, 2011

One Class Into 2 Tables

In some cases we have to create 2 tables out of one class. In such cases those tables must must maintain the referential integrity.

New Annotations Used :
  • @Table(name="Customer")  : Main table (1st table)
  • @SecondaryTable(name="CustomerDetail") : Secondary table
  • @Column(table="CustomerDetail") : Mark the fields which are going to maintain in the second table

© kani.stack.notez 2012 | Blogger Template by Enny Law - Ngetik Dot Com - Nulis