Checkbox ListView

This example will show howto use checkboxes inside a ListView.

First we will create the activity which contain the listview. It extends ListActivity so we only need to set the main layout and create the adapter for the ListView.

Continue reading Checkbox ListView

Autoclose dialog after some time

Example of an dialog in android using the class DialogFragment which will close itself after aproximate three seconds. Basicly is just a DialogFragment which starts a thread when it is shown which will sleep for the three seconds and then close the dialog again.

You can get the full example project at github.

AsyncTask for Image download

If you have an ImageView which will has to display an image which has to be downloaded first it is best practise to download the image in a seperate Task.

The following AsyncTask will download an image from an given URL and assign it to a existing ImageView.

Kill running process

Howto kill a process in Mysql

If you have a “hanging” process in MySQL and want to kill it, you use show processlist to identify the process you want to kill get get the id. Then a simple kill ID will do the job.

mysql> show processlist;

| Id  | User | Host      | db      | Command | Time  | State | Info             |
| 882 | user | localhost | test    | Sleep   | 27111 |       | NULL             |
| 893 | user | localhost | test    | Sleep   |   453 |       | NULL             |
| 901 | user | localhost | NULL    | Query   |     0 | NULL  | show processlist |
3 rows in set (0.00 sec)

mysql> kill 882

The same can be done using mysqladmin form the command line:

    [root@host]# mysqladmin processlist
    | Id  | User | Host      | db      | Command | Time | State | Info             |
    | 882 | prog | localhost | test    | Sleep   | 2676 |       |                  |
    | 893 | prog | localhost |         | Sleep   | 1823 |       |                  |
    | 903 | root | localhost |         | Query   | 0    |       | show processlist |

    [root@host]# mysqladmin kill 882

Link to the MySQL documentation

KILL Syntax

Compare two MySQL databases

If you need to compare the structure or maybe even the content of two MySQL databases you will need a tool which will help you with this not too straight task. Here is an overview of some application which will help you succeeding the work.

Percona Toolkit 
Has several database comparison and syncing tools among other things.

Open source library for tracking, managing and applying database changes.

Can do both a “Schema Compare” as well as a “Data Compare”

MySQL Diff
Free command line tool. Does a good job comparing the table structures, but does not support all MySQL features.

It is not free but doing a very good job in comparing databases.

Connect to MySQL with Perl using DBI

Example of a connection to MySQL with Perl using DBI



If you have to store big texts in MySQL you have to choose in between using a big VARCHAR column and the TEXT type. So what are the differences between using for example a VARCHAR(2000) and TEXT?

The difference between TEXT and the VARCHAR type is how MySQL is storing the data. TEXT (and BLOB) data is stored off the table, leaving only a pointer to the actual storage.

So using VARCHAR is faster when the size of the data is reasonable. How big the performance difference is depends on the data and the used hardware.

Due the row length limit of 65,535 bytes the data you can store in the table itself is limited (Using utf8 2000 chars could use up to 6000 bytes).

Quick Status in MySQL

To get a briest status overview of your MySQL server, you can use the command \\n, it will give you a fast idea of the version you are running, the most important settings and an overview of the amount of running queries.

Getting XML and HTML output.

Many people use MySQL in the console to execute a simple command, but did you know that MySQL can format the result of the query directly to XML or html?

The option -X will output the query result as XML
-H can be used to generate a HTML table containing the data.

$ mysql -X -e "select * from test" test


Output as HTML

$ mysql -H -e "select * from test" test

Android MySQL clients images

A picture is worth a thousand words ..

In addition to my post I made some screenshots of all the existing MySQL clients available in android. Sometimes it is alot easier to decide for or against an application viewing some simple screenshots.


[nggallery id=3]


[nggallery id=4]


[nggallery id=5]

Mysql now

[nggallery id=8]


[nggallery id=9]

If you want to read more about these MySQL clients, please read my post.