CORE API / CATATAN</>↗Core API12 Mei 2010
The following code snippet demonstrates how to get the time for how long has the JVM been running. package org.kodejava.lang.management; import java.lang.management.ManagementFactory; import java.lang.management.RuntimeMXBean; public class GetUptime { public static void main(String[] args) { RuntimeMXBean bean = ManagementFactory.getRuntimeMXBean(); // Returns the uptime of the Java virtual machine in // milliseconds. long uptime = bean.getUptime(); System.out.printf("Uptime...
JDBC / CATATAN</>↗JDBC07 Mei 2010
package org.kodejava.jdbc; import java.sql.DriverManager; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; public class SqlLimitExample { private static final String URL = "jdbc:mysql://localhost/kodejava"; private static final String USERNAME = "kodejava"; private static final String PASSWORD = "s3cr*t"; public static void main(String[] args) { try (Connection connection = DriverManager.getConnection(URL,...
CORE API / CATATAN</>↗Core API06 Mei 2010
A StringBuffer is like a String, but can be modified. StringBuffer are safe for use by multiple threads. The methods are synchronized where necessary so that all the operations on any particular instance behave as if they occur in some serial order that is consistent with the order of the method calls made by each […]
JDBC / CATATAN</>↗JDBC05 Mei 2010
Fetch size is the number of rows that should be fetched from the database on a single database network trip. When more rows are needed, another request is sent by the application to the database server. Setting the correct fetch size will help our program to perform better by reducing the network communication generated between […]
CORE API / CATATAN</>↗Core API02 Mei 2010
package org.kodejava.lang; public class StringBufferInsert { public static void main(String[] args) { StringBuffer buffer = new StringBuffer("kodeava"); System.out.println("Text before = " + buffer); // |k|o|d|e|a|v|a|…. // 0|1|2|3|4|5|6|7|… // // From the above sequence you can see that the index of the // string is started from 0, so when we insert a string in // […]
CORE API / CATATAN</>↗Core API02 Mei 2010
The example below show you to remove some elements of the StringBuffer. We can use the delete(int start, int end) method call to remove some characters from the specified start index to end end index. We can also remove a character at the specified index using the deleteCharAt(int index) method call. package org.kodejava.lang; public class […]