Pagination with Apache iBatis SqlMaps

Posted by Mike Haller on Sunday, November 30. 2008 at 17:37 in Java, SQL
Doing pagination with Apache iBatis SqlMaps is really simple and straightforward. Pagination is when a database connection is queried for a sublist of objects instead for the full list of objects. This is often the case for web application when it's not desirable to display the full contents of a database table to the users all at once. Hence the name pagination: the user can "scroll" through the results using pages. Each page contains a collection of objects and the pages usually are ordered.

Java heap dumps

Posted by Mike Haller on Monday, November 24. 2008 at 10:00 in Java
For analysis of memory leaks in Java applications, the heap dump is an essential source of information which is quite helpful. The dump files can be analyzed with tools like Eclipse Memory Analyzer Tool.

To get a heap dump, there are multiple ways. The first, which should be enabled in all circumstances and especially on production systems, is by adding a VM option. By enabling -XX:+HeapDumpOnOutOfMemory, a heap dump is automatically written to disk when OutOfMemoryErrors occur.

The second way is to manually force a heap dump at runtime at any point of time, without the need of an actual OutOfMemoryError. For this to work, you need to enable Java Management Extensions. Enable JMX by adding the following system properties to your launch configuration of Tomcat:


-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port="9004"
-Dcom.sun.management.jmxremote.authenticate="false"
-Dcom.sun.management.jmxremote.ssl="false"


Now run the following code to get a dump of the heap at runtime:

String url = "service:jmx:rmi:///jndi/rmi://localhost:9004/jmxrmi";
JMXServiceURL jmxURL = new JMXServiceURL(url);
JMXConnector connector = JMXConnectorFactory.connect(jmxURL);
MBeanServerConnection connection = connector.getMBeanServerConnection();
String hotSpotDiagName = "com.sun.management:type=HotSpotDiagnostic";
ObjectName name = new ObjectName(hotSpotDiagName);
String operationName = "dumpHeap";
File tempFile = File.createTempFile("heapdump", ".hprof");
tempFile.delete();
String dumpFilename = tempFile.getAbsolutePath();
Object[] params = new Object[] { dumpFilename, Boolean.TRUE };
String[] signature = new String[] { String.class.getName(), boolean.class.getName() };
Object result = connection.invoke(name, operationName, params, signature);
System.out.println("Dumped to " + dumpFilename);

Eclipse Summit Europe 2008, Part 2

Posted by Mike Haller on Thursday, November 20. 2008 at 21:18 in Eclipse
Eclipse Summit Europe 2008, Part 2

The day (Thursday, 20.11.2008) began with the keynote of David Wood from Symbian. He talked about why mobile software must go open source and how they're going to approach it or already doing it. Some time in the future, they're going to move on to the SFL and EPL licenses with their 40 million lines of code. He sees the claims of the open source community to be for example "faster time to market", "more eyeballs looking on the code" and lower barriers of collaboration. They seem to focus on the lower barriers. He gave a short overview of some licensing models, including weak and strong copyleft. Interesting was the part about the "Six laws of fragmentation", where one solution is clear leadership for the coding together with a powerful platform, which is therefore unlikely to be forked. As forks would be fragmentation. He sees Java as one sort of "intermediate layer" to hide OS diversity from an application.

Eclipse Summit Europe 2008, Part 1

Posted by Mike Haller on Wednesday, November 19. 2008 at 21:41 in Eclipse
Eclipse Summit Europe 2008, Part 1

This year's the first time I attended an Eclipse-related conference: the Eclipse Summit Europe 2008 in Ludwigsburg near Stuttgart in Germany. There were so many intersting talks on the schedule and so i didn't plan exactly to which i'm going to listen to. I arrived in Ludwigsburg on 19.11.2008 at the "Forum am Schlosspark" just in time for the Keynote of Dave Thomas at 9 o'clock.

About

My name is Mike Haller and I'm a software developer and architect at Bosch Software Innovations in Germany. I love programming, playing games and reading books. I like good food, making photos and learning and mentoring about the craftsmanship of commercial software development. Stack Overflow profile for mhaller

Quicksearch