Thursday, December 17, 2009

Search a date range using a date range in sql

select count(*) from tablename where (@startDate between startDate and endDate )

or (@endDate between startDate and endDate)

or (@startDate <> endDate )


If this sql returns greater than 0, that means there exists a conflict with your date interval and the db working set.

Saturday, November 14, 2009

Google Go is coming fast :)

Go is …

… simple

package main

import "fmt"

func main() {
fmt.Printf("Hello, 世界\n")
}

… fast

Go compilers produce fast code fast. Typical builds take a fraction of a second yet the resulting programs run nearly as quickly as comparable C or C++ code.

… safe

Go is type safe and memory safe. Go has pointers but no pointer arithmetic. For random access, use slices, which know their limits.

… concurrent

Go promotes writing systems and servers as sets of lightweight communicating processes, called goroutines, with strong support from the language. Run thousands of goroutines if you want—and say good-bye to stack overflows.

… fun

Go has fast builds, clean syntax, garbage collection, methods for any type, and run-time reflection. It feels like a dynamic language but has the speed and safety of a static language. It's a joy to use.

… open source

Go for it.

Thursday, June 18, 2009

Searching a string in another string

 String string = "Madam, I am Adam";

// Starts with
boolean b = string.startsWith("Mad"); // true

// Ends with
b = string.endsWith("dam"); // true

// Anywhere
b = string.indexOf("I am") > 0; // true

// To ignore case, regular expressions must be used

// Starts with
b = string.matches("(?i)mad.*");

// Ends with
b = string.matches("(?i).*adam");

// Anywhere
b = string.matches("(?i).*i am.*");

Thursday, May 28, 2009

Inversion of Control

IOC is a kind of design principle; stands for abstraction of implementations from user. For example there exists a number of implementations of Interface pizzaDelivery().
One of them makes pizza in 20 minutes and the other makes in 50 minutes but both of them makes pizza. We call the interface and never think about the implementation and wait for the process to be completed, may be an example of IOC principle. By using this, we develop our codes by not caring about other peoples code or implementation. And by this we can focus on our active work, and build up a layered architecture.

Tuesday, April 21, 2009

VALIDATION PROBLEMS WERE FOUND problem: cvc-enumeration-valid

Exception:
VALIDATION PROBLEMS WERE FOUND problem: cvc-enumeration-valid:
string value '2.4' is not a valid enumeration value for
web-app-versionType in namespace http://java.sun.com/xml/ns/javaee

Solution:
While I was deploying my project on weblogic server 10.3
I had this exception at deploy ear phase. And I have found
the solution as changing the version of my web.xml
from 2.4 to 2.5.

Wednesday, April 1, 2009

java.lang.NoSuchMethodError: com.lowagie.text.Image.getPlainWidth()F

java.lang.NoSuchMethodError: com.lowagie.text.Image.getPlainWidth()F

at net.sf.jasperreports.engine.export.JRPdfExporter.exportImage(JRPdfExporter.java:1219)

at net.sf.jasperreports.engine.export.JRPdfExporter.exportElements(JRPdfExporter.java:675)

at net.sf.jasperreports.engine.export.JRPdfExporter.exportPage(JRPdfExporter.java:641)

at net.sf.jasperreports.engine.export.JRPdfExporter.exportReportToStream(JRPdfExporter.java:536)

at net.sf.jasperreports.engine.export.JRPdfExporter.exportReport(JRPdfExporter.java:323)


I have changed the jasperreports version to 3.5.0 and itext version from 1.3.1 to 2.1.4 then problem resolved.:)

Friday, March 13, 2009

ConcurrentModificationException

For example, it is not generally permssible for one thread to modify a Collection while another thread is iterating over it.

for(Personel personel : personelList){
if(!personel.getSelected()){
personelList.remove(personel);
}else{
personel.setParent(parent);
}
}

sun