archive “2009/04”

backup from mysql database's routines

by Hamid Reza Fahimi Madjd @ Apr 11, 2009

Sometimes we need get backup just from mysql database's routines.
command below shows us how we can do that:

mysqldump dbname -uusername -p -Rtd > /path/to/your/dump/file
-u username
-p prompt password
-R stored procedures and functions
-t prevent writing table creation
-d "       "       row information
mysql comments no comment

sql IN logical operation for java

by Hamid Reza Fahimi Madjd @ Apr 20, 2009

Hi,
have you ever needed sql IN for java language ?
OK, in this post I'm going to use new java 5 feature (varargs method) to simulate sql IN:

public static boolean in(int i, int... ints) {
Arrays.sort(ints);
return Arrays.binarySearch(ints, i) >= 0;
}

as you see, our function gets 2 parameters, first one is your desired value and second one is your search list.
now, when you call the method:

public static void main(String[] args) {
System.out.println(in(1, 2, 3, 4, 5, 1));
}

it returns:

true

i hope you find this tip useful;

java comments no comment

last tweet