Blog Enterprise Java
A Tallan Initiative
 

mySQL –i-am-a-dummy

March 25th, 2008

Not Java related, but since most apps deal with databases, this is something new about mySQL I learned today!

(from the mySQL manual)

For beginners, a useful startup option is --safe-updates (or --i-am-a-dummy, which has the same effect). This option was introduced in MySQL 3.23.11. It is helpful for cases when you might have issued a DELETE FROM tbl_name statement but forgotten the WHERE clause. Normally, such a statement deletes all rows from the table. With --safe-updates, you can delete rows only by specifying the key values that identify them. This helps prevent accidents.

When you use the --safe-updates option, mysql issues the following statement when it connects to the MySQL server:

SET SQL_SAFE_UPDATES=1,SQL_SELECT_LIMIT=1000, SQL_MAX_JOIN_SIZE=1000000;

See Section 12.5.3, “SET Syntax”.

The SET statement has the following effects:

 

  • You are not allowed to execute an UPDATE or DELETE statement unless you specify a key constraint in the WHERE clause or provide a LIMIT clause (or both). For example:
    UPDATE tbl_name SET not_key_column=val WHERE key_column=val;
    
    UPDATE tbl_name SET not_key_column=val LIMIT 1;
  • The server limits all large SELECT results to 1,000 rows unless the statement includes a LIMIT clause.
  • The server aborts multiple-table SELECT statements that probably need to examine more than 1,000,000 row combinations.

To specify limits different from 1,000 and 1,000,000, you can override the defaults by using the --select_limit and --max_join_size options:

EclEmma - Unit Test Coverage Analysis in Eclipse

March 24th, 2008

I was recently looking for a unit test coverage analyzer such as JCoverage for a project I’m working on. After reviewing several tools I discovered an amazing free tool called EclEmma.

I’ve used JCoverage in the past and while it’s HTML based reports are useful for project managers they are less so for developers. This tool essentially gives you the same information, but directly in Eclipse. You simply run the analyzer on either a single class or a set of classes and viola… you have your coverage report.

It even color codes each line of code within your editor window.

Use the http://update.eclemma.org/ update site to install EclEmma.

Welcome to Blog Enterprise Java!

March 24th, 2008

Welcome to Blog Enterprise Java! This blog was create and is owned by a group Java developers within Tallan. Within here we will post articles, techniques, reviews, etc… related to the field of enterprise Java.

 
� 2008 BlogEnterpriseJava.com All rights reserved. Tallan, Inc.