বৃহস্পতিবার, ২৬ এপ্রিল, ২০১২

Spring 3 MVC - DynamicJasper Integration Tutorial

http://krams915.blogspot.com/2010/12/spring-3-mvc-dynamic-jasper-integration.html

মঙ্গলবার, ১৭ এপ্রিল, ২০১২

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

problem: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

probable solution for linux :
1. sudo /etc/init.d/mysqld start
2. mysql -u username -p
(then password)

সোমবার, ১৬ এপ্রিল, ২০১২

InnoDB vs MyISAM on MySQL

MySQL know that MyISAM and InnoDB are the two most-common database engines available with the popular open-source database provider

MyISAM

Let's start with MyISAM since it is the default engine with MySQL. MyISAM is based on the older but proven ISAM code but has been extended to be fully-featured while retaining the reliability. Data in MyISAM tables is split between three different files on the disk. One for the table format, another for the data, and lastly a third for the indexes.

The maximum number of rows supported amounts to somewhere around ~4.295E+09 and can have up to 64 indexed fields per table. Both of these limits can be greatly increased by compiling a special version of MySQL.

Text/Blob fields are able to be fully-indexed which is of great importance to search functions.

Much more technical information can be found on MySQL's MyISAM Manual Page.

InnoDB

InnoDB is relatively newer so the scene than MyISAM is so people are still weary about its use in environments than run fine under MyISAM. InnoDB is transaction-safe meaning data-integrity is maintained throughout the entire query process. InnoDB also provides row-locking, as opposed to table-locking, meaning while one query is busy updating or inserting a row, another query can update a different row at the same time. These features increase multi-user concurrency and performance.

Another great feature InnoDB boasts is the ability to use foreign-key constraints. FK constraints allows developers to ensure that inserted data referencing another table remains valid. For example, if you had an authors table and a books table and you wanted to insert a new book while referencing the author. The author would have to exist in the authors table before inserting them in the books table because a foreign key was specified in the books table. At the same time you would not be able to delete an author from the authors table if they had any entries associated with them in the books table.

Because of its row-locking feature InnoDB is said to thrive in high load environments. Its CPU efficiency is probably not matched by any other disk-based relational database engine.

Comparison

MyISAM in most cases will be faster than InnoDB for run of the mill sort of work. Selecting, updating and inserting are all very speedy under normal circumstances. It is the default engine chosen by the MySQL development team which speaks to its integrity, reliability, and performance.

InnoDB, has emerged with some nifty features and created a niche for itself very quickly. Boasting features like row-level locking, transaction-safe queries, and relational table design are all very temping. The first two features really shine in a table that is constantly getting hammered like a logs, or search engine-type table. Since queries happen in the blink of an eye (faster actually) table-level locking(MyISAM) is sufficient in most other normal cases.

InnoDB recovers from a crash or other unexpected shutdown by replaying its logs. MyISAM must fully scan and repair or rebuild any indexes or possibly tables which had been updated but not fully flushed to disk.

Decision Matrix

Is your table is going to be inserted, deleted, and updated much much more than it is going to be selected?
InnoDB
If you need full-text search MyISAM
If you prefer/require relational database design InnoDB
Is disk-space or ram an issue? MyISAM
In Doubt? MyISAM

There is no winner.

REMEMBER! It's OK to mix table types in the same database! In fact it's recommended and frequently required. However, it is important to note that if you are having performance issues when joining the two types, try converting one to the other and see if that fixes it. This issue does not happen often but it has been reported.

রবিবার, ১৫ এপ্রিল, ২০১২


Setup ant file ..... more

Here I write something about build script file......

I used one build.propeties and build.xml file. Both file are in same directory in project folder.

My ant file expect above project structure(that is shown above):


setting information about tomcat server on build.properties:

tomcat.home=/usr/local/tomcat6
deploy.path=${tomcat.home}/webapps
appContext={your project name}

On build.xml:

<?xml version="1.0" encoding="UTF-8"?>

<project name="birth-certificate" default="deploy" basedir=".">

<description>
birth certificate
</description>

<property file="build.properties"/>
<property name="src.dir" location="${basedir}/src"/>
<property name="web.dir" location="${basedir}/web"/>
<property name="lib.dir" location="${basedir}/lib"/>
<property name="props.dir" location="${basedir}/props"/>
<property name="i18n.dir" location="${basedir}/i18n"/>

<property name="build.dir" location="/tmp/build"/>
<property name="classes.dir" location="${build.dir}/WEB-INF/classes"/>
<property name="dist.dir" location="${basedir}/dist"/>

<property name="tomcat.lib" value="${tomcat.home}/lib"/>

<path id="classpath">
<fileset dir="${lib.dir}">
<include name="*.jar"/>
</fileset>

<fileset dir="${tomcat.lib}">
<include name="*.jar"/>
</fileset>
</path>


<target name="init">
<tstamp>
<format property="build.tstamp" pattern="yyyy-MM-dd HH:mm:ss"/>
</tstamp>
<echo message="Build timestamp: ${build.tstamp}"/>
<mkdir dir="${classes.dir}"/>
</target>

<target name="resources" depends="init" description="prepare deployment resources">
<copy todir="${build.dir}">
<fileset dir="${web.dir}"/>
</copy>

<mkdir dir="${build.dir}/WEB-INF/lib"/>

<copy todir="${build.dir}/WEB-INF/lib">
<fileset dir="${lib.dir}">
<include name="*.jar"/>
</fileset>
</copy>

<copy todir="${classes.dir}">
<fileset dir="${props.dir}"/>
<fileset dir="${i18n.dir}"/>
</copy>
</target>


<target name="compile" depends="init">
<javac destdir="${classes.dir}"
classpathref="classpath"
srcdir="${src.dir}"
debug="on"
includeantruntime="false"/>
</target>

<target name="clean">
<delete dir="${build.dir}"/>
</target>

<target name="build" depends="clean, resources, compile"/>

<target name="start">
<exec executable="${tomcat.home}/bin/catalina.sh">
<arg value="start"/>
</exec>
</target>

<target name="stop">
<exec executable="${tomcat.home}/bin/catalina.sh">
<arg value="stop"/>
</exec>
</target>

<target name="remove-deployment">
<delete file="${deploy.path}/${appContext}.war"/>
<delete dir="${deploy.path}/${appContext}"/>
</target>

<target name="undeploy" depends="stop, remove-deployment, start" description="UnDeploy Application"/>

<target name="copy-war" depends="clean, build">
<copy todir="${deploy.path}" file="${dist.dir}/${appContext}.war"/>
</target>

<target name="war" depends="clean, build">
<mkdir dir="${dist.dir}"/>
<war destfile="${dist.dir}/${appContext}.war" webxml="${build.dir}/WEB-INF/web.xml">
<fileset dir="${build.dir}"/>
</war>
</target>

<target name="copy" depends="clean, build">
<copy todir="${deploy.path}/${appContext}">
<fileset dir="${build.dir}"/>
</copy>
</target>

<target name="deploy-war" depends="stop, copy-war, start"/>

<target name="deploy" depends="stop, copy, start"/>


<!--=============================build some extra features===========================-->

<target name="static" description="Copy JSP files and Static contents">
<copy todir="${deploy.path}/${appContext}">
<fileset dir="${web.dir}">
<include name="**/*.jsp"/>
</fileset>
</copy>

<copy todir="${deploy.path}/${appContext}/css">
<fileset dir="${web.dir}/css"/>
</copy>

<copy todir="${deploy.path}/${appContext}/images">
<fileset dir="${web.dir}/images"/>
</copy>

<copy todir="${deploy.path}/${appContext}/js">
<fileset dir="${web.dir}/js"/>
</copy>
</target>


<target name="debug">
<exec executable="${tomcat.home}/bin/catalina.sh">
<arg value="jpda"/>
<arg value="start"/>
</exec>
</target>
</project>

রবিবার, ৮ এপ্রিল, ২০১২

fibonacci number

public class FibonacciNo {
public FibonacciNo() {
calculate(10);
System.out.println("\n recursive fibo "+ fibo(10));
}

private void calculate(int limit) {
int[] tempArray = new int[limit+2];
tempArray[0] = 0;
tempArray[1] = 1;
for(int i =1 ;i<=limit;i++){
tempArray[i+1] = tempArray[i-1] + tempArray[i];
}
for(int i=0;i<=limit;i++){
System.out.print(tempArray[i]+" ");
}
}

private int fibo(int n){
if(n==0) return 0;
if(n==1) return 1;
return fibo(n - 1)+ fibo(n - 2);
}


public static void main(String[] a) {
new FibonacciNo();
}
}

factoiral number

/**
* User: shohan
* Date: 4/8/12
*/
public class FactorialNo {

public FactorialNo() {

int result = calculateFactorialNo(10);
System.out.println("normal result : "+result);
System.out.println("recursive result : "+calculate(10));

}

private int calculateFactorialNo(int i) {
int result = 1;
for (int j = 1; j <= i; j++) {
result *= j;
}
return result;
}

private int calculate(int n){
if(n==0) return 1;
return n*calculate((n-1));
}

public static void main(String [] arg){
new FactorialNo();
}
}

Multiple div in one div

<html>
<style type="text/css">
div
{
margin:10 10 10 10;
border:1px solid;
border-radius:25px;
-moz-border-radius:5px;
}
.test{
width:200px;
}
a{
text-decoration:none
}
.subMain{
width:250px;
padding:5px;

}
</style>
<body>


<div style="float:left; width: 600px;">

<div style="float:left; border:0px; width= 500px;">
<div class="subMain"style="float:left">dddd dfdfd fdfsdf s fsdfsdf sdfsdfsdfsdfsdf sfsdfsd sfsdfd sdfsdfd<a href="#">more...</a></div>
<div class="subMain"style="float:right">dddd dfdfd fdfsdf s fsdfsdf sdfsdfsdfsdfsdf sfsdfsd sfsdfd sdfsdfd<a href="#">More...</a></div>
</div>
<div style="float:left; border:0px;">
<div class="subMain"style="float:left">dddd dfdfd fdfsdf s fsdfsdf sdfsdfsdfsdfsdf sfsdfsd sfsdfd sdfsdfddddd dfdfd fdfsdf s fsdfsdf sdfsdfsdfsdfsdf sfsdfsd sfsdfd sdfsdfd<a href="#">More...</a></div>
<div class="subMain"style="float:right">dddd dfdfd fdfsdf s fsdfsdf sdfsdfsdfsdfsdf sfsdfsd sfsdfd sdfsdfddddd dfdfd fdfsdf s fsdfsdf sdfsdfsdfsdfsdf sfsdfsd sfsdfd sdfsdfddddddfdf dfsdfdf<a href="#">More...</a></div>
</div>


</div>
</body>
</html>

বৃহস্পতিবার, ৫ এপ্রিল, ২০১২

Balsamiq Mockups

http://www.douban.com/group/topic/21967889/

Prime Number genrator

public class PrimeNo {

public PrimeNo() {
int givenNo = 9234563;

boolean isPrime = checkPrimeNumber(givenNo);

boolean isPrimeEfficient = getPrimeNumber(givenNo, getDivisorsArray(givenNo));

System.out.println(isPrime);
System.out.println("efficient");
System.out.println(isPrimeEfficient);

}



private boolean getPrimeNumber(int givenNo, int[] divisorsArray) {
if (givenNo == 2) return true;
if (givenNo > 2 && givenNo % 2 != 0) {
if (divisorsArray.length != 0) {
for (int j = 3; j <= divisorsArray.length; j++) {
if (givenNo % j == 0) {
return false;
}
}
}
return true;
}
return false;
}

public static void main(String arg[]) {
new PrimeNo();
}

private int[] getDivisorsArray(int givenNo) {

int sqrt = (int) Math.sqrt(givenNo);
int[] tempArray = new int[sqrt];
int count = 0;
for (int i = 3; i < sqrt; i++) {
if (checkPrimeNumber(i)) {
tempArray[count++] = i;
}
}

return tempArray;
}

private boolean checkPrimeNumber(int i) {
if (i == 2) return true;
if (i > 1 && i % 2 != 0) {
for (int j = 3; j <= Math.sqrt(i); j++) {
if (i % j == 0) {
return false;
}
}
return true;
}
return false;
}
}

বুধবার, ৪ এপ্রিল, ২০১২