APACHE COMMONS / CATATAN</>↗Apache Commons10 Agt 2011
This example demonstrates how to use the BasicDataSource class of Apache Commons DBCP to create a basic requirements for database connection. The configuration of the data source can be defined using some property method provided by this class. The basic properties are the driver classname, connection url, username and password. After the datasource ready we […]
APACHE COMMONS / CATATAN</>↗Apache Commons10 Agt 2011
This example shows you how to create a connection pool implementation using the Apache Commons DBCP library. package org.kodejava.commons.dbcp; import org.apache.commons.dbcp2.*; import org.apache.commons.pool2.impl.GenericObjectPool; import org.apache.commons.pool2.impl.GenericObjectPoolConfig; import javax.sql.DataSource; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; public class ConnectionPoolExample { private static final String...
SPRING CORE / CATATAN</>↗Spring Core22 Jul 2011
In this example we will learn how to declare a bean in Spring Application. We are going to build a simple Maven project to demonstrate it. So let’s begin by setting up our Maven project. Creating a Maven Project Below is the directory structure of our Maven Project. . ├─ pom.xml └─ src └─ main […]
CORE API / CATATAN</>↗Core API19 Jun 2011
This example demonstrates how to get print service’s attribute set using the javax.print API. First we find the default printer for the current machine using the PrintServiceLookup class. This will give us a PrintService object, this object might be null if no print service found. The final step is to get the print service attribute […]
CORE API / CATATAN</>↗Core API15 Jun 2011
To format a java.util.Date object we use the SimpleDateFormat class. To get back the string pattern that were used to format the date we can use the toPattern() method of this class. package org.kodejava.text; import java.text.SimpleDateFormat; import java.util.Date; public class SimpleDateFormatToPattern { public static void main(String[] args) { SimpleDateFormat format = new SimpleDateFormat("EEEE, dd/MM/yyyy"); // […]
CORE API / CATATAN</>↗Core API15 Jun 2011
The example presented in this code snippet show you how to get the available currency codes. We will need the locale information and use the Currency class for this example. package org.kodejava.util; import java.util.Currency; import java.util.Locale; import java.util.Map; import java.util.TreeMap; public class CurrencySymbolDemo { public static void main(String[] args) { CurrencySymbolDemo cs = new CurrencySymbolDemo(); […]