Tuesday 2009-10-06
When you use Spring and Ibatis and SQLTemplates, you could have code in your project which looks somewhat like this:
Connection connection = DataSourceUtils.getConnection(getDataSource());
...<do connection stuff here>...
DataSourceUtils.releaseConnection(connection, getDataSource());
Sonar will report that you did not close the connection, while in fact, Spring did that for you. You can not just add a “connection.close()” to the code because the whole point of calling “releaseConnection()” is to have Spring handle all the smart stuff on committing, closing, and returning the connection to the pool if needed.
In our company, not closing the connection is a major blocking violation (and it should be). But in this case, there is no way to make the Jedi wave to Sonar, telling it that “this code will do just fine”. So I added the following trick, albeit a bit dirty:
if (connection.isClosed()){
// This code is only here to keep Sonar from
// warning us that the connection is not
// closed. Please note: Do not just close an
// unclosed connection, Spring should handle
// connection closing and returning to the pool.
connection.close();
}
Use it to your advantage, but use this responsibly. If you see any problems in my solution, or if there is a better way to do this I’d be happy to hear about it.
5 Comments |
Software | Tagged: hacking, Java, programming, Sonar, Spring |
Permalink
Posted by rolfje
Friday 2009-09-11
What I loved about iTunes is the three pane “Genre-Artist-Album” on top of my music list. It allowed me to quickly go through my music and find that great Anouk album I was looking for. After installing iTunes 9, it was gone. And I was sad. But I found a way to get it back.

Look at this screenshot (sorry, it’s in Dutch). In iTunes, select “View”, “Show Column Browser”. Now, put it on top by selecting “View”, “Column Browser”, “Top”. Voila, your trusted browser is at the top. You may need to add “Genre” and “Album” there, but you’ve already seen the options for that now, have you?
17 Comments |
Apple | Tagged: Apple, iTunes, music |
Permalink
Posted by rolfje
Saturday 2009-08-29
At work, we have two applications which connect to the same database. For all kinds of business reasons, we need to make sure that only one of the applications accesses certain data at the same time. To do this, we use a row in a table as a semaphore.
While working on the locking mechanism, we had a closer look at the Transaction Management and the Isolation Levels we were using. There is a lot of good documentation on Transaction and Isolation, but it tends to be over complete, elaborate and therefore hard to read. I’ll try to share our insights with you in a slightly more digestable form (I hope).
Read the rest of this entry »
2 Comments |
Software | Tagged: database, oracle, programming |
Permalink
Posted by rolfje