I/O VIsion

Do one thing at a time, and do well.

Simple Git Guide

| Comments


In software development, Git is a distributed revision control and source code management (SCM) system with an emphasis on speed initially designed and developed by Linus Torvalds. Every Git working directory is a full-fledged repository with complete history and full version tracking capabilities, not dependent on network access or a central server.

Since each developer’s working copy is a bona fide Git repository, there are multiple possibilities for working with Git. In a larger team setting, you might actually prefer an approach similar to client-server systems, where you maintain one “master” repository which each developer pulls from and pushes to. For a small team (say, two or three developers) it may be effective to have each developer pull changes from, and push changes to, each of the others directly. And if you’re a solo developer, then one Git repository on your development machine is likely all you need.

Abbreviation in Linux System

| Comments

Unix is 35. Some people consider that the official start of middle age, although for a computer technology it’s more like existing since the Middle Ages. Over that time, Unix and its child Linux have collected a lot of history and some quite archaic language. In this tip, we’ll have a look at a few of the more ancient bits of crusty stuff and identify their purposes, if not their actual origins.


Perhaps the most common abbreviation in Linux is “rc,” short for “runcomm” — short in term for “run command.” Today, “rc” is a suffix added to any script-like file that is called during the startup stage of a program, or of Linux in general. Thus /etc/rc is the master script for Linux startup, and .bashrc is the script that runs when the bash shell starts. The “.” prefix on .bashrc is a naming standard designed only to hide user-specific administrative files from user files; the “ls” command doesn’t list such files by default, and “rm” doesn’t delete them by default. Many programs demand that startup files or profile files begin with a period or have an “rc” suffix, but there’s nothing magical about either from the file system’s perspective.

Java Performance Tuning Tips

| Comments

The 1st version is completed on 2013.12.11, the main content is from Performance Tuning of Java Applications.

Ever since the first version of Java Technology hit the streets, performance has been an important issue for Java developers. Java has improved dramatically and continually but, performance tuning is very essential to get the best results, especially when we think of J2EE applications.

Best Practices to Improve Performance in JDBC

| Comments

The 1st version is completed on 2013.11.11 20:38.

The 2nd version is completed on 2013.11.22, which modified completely, the main content is from Best practices to improve performance in JDBC, this is a great article about JDBC tuning.

This post is dedicated to illustrate techniques for optimizing JDBC API-based calls from the Java platform. As a result of this presentation, you will:

  • Design better JDBC implementations
  • Recognize potential performance bottlenecks
  • Reduce cost during development

Optimal JDBC Transaction Isolation Level

| Comments

Choose optimal isolation level

Isolation level represent how a database maintains data integrity against the problems like dirty reads, phantom reads and non-repeatable reads which can occur due to concurrent transactions. java.sql.Connection interface provides methods and constants to avoid the above mentioned problems by setting different isolation levels.

public interface Connection {
    public static final int  TRANSACTION_NONE                 = 0
    public static final int  TRANSACTION_READ_UNCOMMITTED     = 1
    public static final int  TRANSACTION_READ_COMMITTED       = 2
    public static final int  TRANSACTION_REPEATABLE_READ      = 4
    public static final int  TRANSACTION_SERIALIZABLE         = 8
    int    getTransactionIsolation();
    void   setTransactionIsolation(int isolationlevelconstant);

Optimistic and Pessimistic Locking

| Comments

Locking Introduction

This article talks about serveral ways of doing locking. It starts with concurrency problems and then discusses about 2 ways of doing optimistic locking. As optimistic locking does not solve the concurrency issues from roots, it introduces pessimistic locking. It then moves ahead to explain how isolation levels can help us implement pessimistic locking. Each isolation level is explained with sample demonstration to make concepts clearer.

Why do we need locking?

In multi-user environment it’s possible that multiple users can update the same record at the same time causing confusion between users. This issue is termed as concurrency.

How to Backup or Restore MySQL Database

| Comments

The Way You Need to Know

  1. Back up From the Command Line
  2. Operations over Web with PHPMyAdmin

Back up From the Command Line (using mysqldump)

If you have shell or telnet access to your web server, you can backup your MySQL data by using the mysqldump command. This command connects to the MySQL server and creates an SQL dump file. The dump file contains the SQL statements necessary to re-create the database. Here is the proper syntax:

  • mysqldump --opt -u [uname] -p[pass] [dbname] > [backupfile.sql]
    This command will backup the ‘Tutorials’ database into a file called tut_backup.sql which will contain all the SQL statements needed to re-create the database.

  • mysqldump -u root -p Tutorials php_tutorials asp_tutorials > tut_backup.sql
    With mysqldump command you can specify certain tables of your database you want to backup. For example, to back up only php_tutorials and asp_tutorials tables from the ‘Tutorials’ database accomplish the command below. Each table name has to be separated by space.

  • mysqldump -u root -p --databases Tutorials Articles Comments > content_backup.sql
    Sometimes it is necessary to back up more that one database at once. In this case you can use the —database option followed by the list of databases you would like to backup. Each database name has to be separated by space.

  • mysqldump -u root -p --all-databases > alldb_backup.sql
    If you want to back up all the databases in the server at one time you should use the —all-databases option. It tells MySQL to dump all the databases it has in storage.

The mysqldump command has also some other useful options:

  1. --add-drop-table: Tells MySQL to add a DROP TABLE statement before each CREATE TABLE in the dump.

  2. --no-data: Dumps only the database structure, not the contents.

  3. --add-locks: Adds the LOCK TABLES and UNLOCK TABLES statements you can see in the dump file.

The mysqldump command has advantages and disadvantages. The advantages of using mysqldump are that it is simple to use and it takes care of table locking issues for you. The disadvantage is that the command locks tables. If the size of your tables is very big mysqldump can lock out users for a long period of time.

Back up your MySQL Database with Compress

  • mysqldump -u [uname] -p[pass] [dbname] | gzip -9 > [backupfile.sql.gz]
    If your mysql database is very big, you might want to compress the output of mysqldump. Just use the mysql backup command below and pipe the output to gzip, then you will get the output as gzip file.

  • gunzip [backupfile.sql.gz]
    If you want to extract the .gz file, use the command above:

  • Restoring your MySQL Database
    Above we backup the Tutorials database into tut_backup.sql file. To re-create the Tutorials database you should follow two steps:

    1. Create an appropriately named database on the target machine
    2. Load the file using the mysql command:
    3. $ mysql -u [uname] -p[pass] [db_to_restore] < [backupfile.sql]

Have a look how you can restore your tut_backup.sql file to the Tutorials database.

  • To restore compressed backup files you can do the following:
    gunzip < [backupfile.sql.gz] | mysql -u [uname] -p[pass] [dbname]

  • If you need to restore a database that already exists, you’ll need to use mysqlimport command. The syntax for mysqlimport is as follows:
    mysqlimport -u [uname] -p[pass] [dbname] [backupfile.sql]

Operations over Web with PHPMyAdmin

  • It is assumed that you have phpMyAdmin installed since a lot of web service providers use it. To backup your MySQL database using PHPMyAdmin just follow a couple of steps:

    1. Open phpMyAdmin.
    2. Select your database by clicking the database name in the list on the left of the screen.
    3. Click the Export link. This should bring up a new screen that says View dump of database (or something similar).
    4. In the Export area, click the Select All link to choose all of the tables in your database.
    5. In the SQL options area, click the right options.
    6. Click on the Save as file option and the corresponding compression option and then click the Go button. A dialog box should appear prompting you to save the file locally.
  • Restoring your database is easy as well as backing it up. Make the following:

    1. Open phpMyAdmin.
    2. Create an appropriately named database and select it by clicking the database name in the list on the left of the screen. If you would like to rewrite the backup over an 1. existing database then click on the database name, select all the check boxes next to the table names and select Drop to delete all existing tables in the database.
    3. Click the SQL link. This should bring up a new screen where you can either type in SQL commands, or upload your SQL file.
    4. Use the browse button to find the database file.
    5. Click Go button. This will upload the backup, execute the SQL commands and re-create your database.


Short List of MySQL Commands

| Comments

Conventions used here:

  • MySQL keywords are shown in CAPS
  • User-specified names are in small letters
  • Optional items are enclosed in square brackets [ ]
  • Items in parentheses must appear in the command, along with the parentheses
  • Items that can be repeated as often as desired are indicated by an ellipsis …