CORE API / NOTES</>↗Core API21 May 2010
package org.kodejava.lang.management; import java.lang.management.ManagementFactory; import java.lang.management.ThreadMXBean; public class ThreadCount { public static void main(String[] args) { // Get the managed bean for the thread system of the Java // virtual machine. ThreadMXBean bean = ManagementFactory.getThreadMXBean(); // Get the current number of live threads including both // daemon and non-daemon threads. int threadCount = bean.getThreadCount(); System.out.println...
CORE API / NOTES</>↗Core API18 May 2010
The RuntimeMXBean.getClassPath() returns the Java class path that is used by the system class loader to search for class files. This method is equivalent to System.getProperty("java.class.path"). Multiple paths in the Java class path are separated by the path separator character of the platform of the Java virtual machine being monitored. package org.kodejava.lang.management; import java.lang.management.ManagementFactory; import […]
CORE API / NOTES</>↗Core API17 May 2010
package org.kodejava.lang.management; import java.lang.management.ManagementFactory; import java.lang.management.RuntimeMXBean; import java.util.Map; import java.util.Set; public class GetSystemProperties { public static void main(String[] args) { RuntimeMXBean bean = ManagementFactory.getRuntimeMXBean(); // Returns a map of names and values of all system // properties. This method calls System.getProperties() // to get all system properties. Properties whose // name or value...
CORE API / NOTES</>↗Core API14 May 2010
package org.kodejava.lang.management; import java.lang.management.ManagementFactory; import java.lang.management.RuntimeMXBean; import java.util.Date; public class GetStartTime { public static void main(String[] args) { RuntimeMXBean bean = ManagementFactory.getRuntimeMXBean(); // Returns the start time of the Java virtual machine in // milliseconds. This method returns the approximate time // when the Java virtual machine started. long startTime = bean.getStartTime(); Date s...
CORE API / NOTES</>↗Core API12 May 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 / NOTES</>↗JDBC07 May 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,...