27 Nov 2008

Insert big data chunk into MySQL

Inserting 370 000 records in a mysql table was taking ages!
Found this little trick:
LOAD DATA CONCURRENT LOCAL INFILE 'C:\\my\\path\\to\\folder\\records.sql' INTO TABLE FOO;

Useful under Windows and MySQLQueryBrowser ;)

MySQL funny command line option

While searching for help for mysql ubuntu command line tool:

$ mysql --help
Usage: mysql [OPTIONS] [database]
-?, --help Display this help and exit.
...
-U, --i-am-a-dummy Synonym for option --safe-updates, -U.
...

19 Nov 2008

Flag a blog post as deprecated

While looking for some info on capistrano I stumbled on this post: "Ant sucks for FTP deployment - What alternatives do we have?".

The funny thing is the deprecated notice:


I often use @deprecated for the code but I never though of using it for my old blog posts... good idea :)

And it's also a good way to always keep url even if they display wrong or inaccurate info, just like describe in this w3c document "Cool URIs don't change."

Simple Jdbc

I wanted to use spring JdbcTemplate to simplify my jdbc code but I had to add 3 jars just to use it !
  • spring-jdbc.jar
  • spring-tx.jar
  • spring-core.jar


spring-tx.jar because I got this error:
The type org.springframework.dao.DataAccessException cannot be resolved. 
It is indirectly referenced from required .class files
TestSpring.java

spring-core.jar because I got this error:
The type org.springframework.core.NestedRuntimeException 
cannot be resolved. It is indirectly referenced from required .class files
TestSpring.java

And I wasn't even sure about the transaction part, did I need to include spring-beans.jar and spring-context.jar; start to use a TransactionTemplate and configure a PlatformTransactionManager with tons of xml configuration, services and dao(s) :(

So I decided to make a small but simple project doing exactly what I wanted: jdbcTemplate and I made it public on sourceforge.

Don't expect any documentation or support for this, it's just that I don't want to redo this code on my next jdbc project (if that ever happens).




You can also take a look at DbUtils at http://commons.apache.org that does just the same ;)


 

12 Nov 2008

Why you should use JUnit4

I've been using JUnit 4 from time to time but never really understood the benefit moving from version 3 to version 4.

That's because I never took time to take a look at new features :o

Don't be like me ;) Just take a look at this article: "Junit 4 in 60 seconds"

You will discover annotations like:
  • Better Exception Handling with @Test(expected = ArithmeticException.class)
  • @Ignore("Not Ready to Run")
  • @Test(timeout = 1000)

Small enhancements making testing easier and clearer!

5 Nov 2008

New Java Date Time Api

This is a good news: Date and Time API: Round 3. Date and Time parsing is always a mess... if they could just remove the old api (and not be backward compatible) that would be even better but it takes courage.

Come on almost all java.util.Date methods are deprecated since Jdk version 1.1... It's time to change!