বৃহস্পতিবার, ২৬ এপ্রিল, ২০১২
Spring 3 MVC - DynamicJasper Integration Tutorial
মঙ্গলবার, ১৭ এপ্রিল, ২০১২
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
রবিবার, ৮ এপ্রিল, ২০১২
fibonacci number
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
<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>
বৃহস্পতিবার, ৫ এপ্রিল, ২০১২
Prime Number genrator
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;
}
}