MYBATIS / CATATAN</>↗MyBatis10 Jun 2011
In the previous example How do I create MyBatis mapper? you’ve seen how to use a mapper to get a record from the database. In that example the select query is defined in the mapper xml file. For the same functionality MyBatis also offer a solution to use an annotation for the select query. In […]
MYBATIS / CATATAN</>↗MyBatis10 Jun 2011
In this example you will see how to create or define a data mapper using the MyBatis. The mapper will communicate our application with the underlying databases where the data is stored. MyBatis data mapper is defined as an interface object. We can either use annotations or the xml mapper to define our database query. […]
MYBATIS / CATATAN</>↗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 / CATATAN</>↗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 / CATATAN</>↗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 / CATATAN</>↗Core API27 Mei 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 […]