HIBERNATE / CATATAN</>↗Hibernate16 Sep 2007
This example shows you how to store or save Hibernate object to database. The basic steps in creating application in Hibernate will be: Creates the POJO Create hibernate mapping file Register the mapping file in hibernate configuration Create a simple service class to store the object In this example we’ll create a class called Label, […]
HIBERNATE / CATATAN</>↗Hibernate14 Sep 2007
When creating an application the use Hibernate to manage our application persistence object we’ll need a SessionFactory. This factory creates or open a session to talk to a database. To create a SessionFactory we can define the configuration in hibernate.properties, hibernate.cfg.xml or create it programmatically. In this example we’ll use the hibernate.cfg.xml configuration file, which […]
CORE API / CATATAN</>↗Core API12 Sep 2007
package org.kodejava.util; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Calendar; public class MillisecondsToDate { public static void main(String[] args) { // Create a DateFormatter object for displaying date information. DateFormat formatter = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss.SSS"); // Get date and time information in milliseconds long now = System.currentTimeMillis(); // Create a calendar object that will convert the date […]
MAIL / CATATAN</>↗Mail11 Sep 2007
In this example we create a small program to send email with a file attachment. To send message with attachment we need to create an email with javax.mail.Multipart object which basically will contain the email text message and then add a file to the second block, which both of them is an object of javax.mail.internet.MimeBodyPart. […]
CORE API / CATATAN</>↗Core API07 Sep 2007
Instead of using the StringTokenizer class or the String.split() method we can use the java.util.Scanner class to split a string. package org.kodejava.util; import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; public class ScannerTokenDemo { public static void main(String[] args) { // This file contains some data as follows: // a, b, c, d // e, f, g, […]
CORE API / CATATAN</>↗Core API04 Sep 2007
Here is a compact way to read file line by line using the java.util.Scanner class. package org.kodejava.util; import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; public class ScannerReadFile { public static void main(String[] args) { // Create an instance of File for data.txt file. File file = new File("README.md"); try { // Create a new Scanner object […]