MYBATIS / NOTES</>↗MyBatis08 Jun 2011
The example below shows you how to create MyBatis SqlSessionFactory object using an XML configuration. The steps required is to create the configuration file. This file basically contains the connection information to the database and MyBatis configuration such as typeAliases and the mappers. The next steps is to read the configuration file using a org.apache.ibatis.io.Resources […]
MYBATIS / NOTES</>↗MyBatis08 Jun 2011
To create an SqlSession you can use the SqlSessionFactory class openSession() method. This method offers some overloaded method that can configure the property of the session. For example, we can configure the auto-commit-mode and the transaction-isolation-level for the session. package org.kodejava.mybatis; import org.apache.ibatis.io.Resources; import org.apache.ibatis.session.SqlSession; import org.apache.ibatis.session.SqlSessionFactory; import org.apache.ibatis.session.S...
APACHE COMMONS / NOTES</>↗Apache Commons01 Jun 2011
This example show you how to capitalize a string. We use methods from WordUtils class provided by the Apache commons-text;. We can use the WordUtils.capitalize(str) or WordUtils.capitalizeFully(str). Let’s see an example below: package org.kodejava.commons.text; import org.apache.commons.text.WordUtils; public class WordCapitalize { public static void main(String[] args) { // Capitalizes all the whitespace separated words in a […]
CORE API / NOTES</>↗Core API27 May 2011
The objective of thread synchronization is to ensure that when several threads want access to a single resource, only one thread can access it at any given time. You can manage synchronization of your program at method level (synchronized method) or at block level (synchronized block). To make a block of code synchronized you can […]
REFLECTION / NOTES</>↗Reflection12 Dec 2010
The Class.getComponentType() method call returns the Class representing the component type of array. If this class does not represent an array class this method returns null reference instead. package org.kodejava.lang.reflect; public class ComponentTypeDemo { public static void main(String[] args) { String[] words = {"and", "the"}; int[][] matrix = {{1, 1}, {2, 1}}; Double number = […]
REFLECTION / NOTES</>↗Reflection12 Dec 2010
For checking if a class object is representing an array class we can use the isArray() method call of the Class object. This method returns true if the checked object represents an array class and false otherwise. package org.kodejava.lang.reflect; public class IsArrayDemo { public static void main(String[] args) { int[][] matrix = {{1, 1}, {2, […]