CORE API / CATATAN</>↗Core API15 Jun 2010
package org.kodejava.util; import java.util.TimeZone; public class TimeZoneByOffset { public static void main(String[] args) { // Gets the available IDs according to the given time zone // offset in milliseconds. int offset = 8 * 60 * 60 * 1000; String[] timezones = TimeZone.getAvailableIDs(offset); System.out.println("List of available IDs for GMT:+08:00"); System.out.println("===================================="); for (String id : timezones) […]
JDBC / CATATAN</>↗JDBC15 Jun 2010
The examples below show you how to get the available catalog names in MySQL database. The available catalog names can be obtained from the DatabaseMetaData object by calling the getCatalogs() method. This method returns a ResultSet object. We iterate it and get the schema name by calling the getString() method and pass TABLE_CAT as the […]
CORE API / CATATAN</>↗Core API12 Jun 2010
In this example you’ll see how to create a simple port scanner program to check the open ports for the specified host name. package org.kodejava.net; import java.io.IOException; import java.net.InetAddress; import java.net.Socket; public class PortScanner { public static void main(String[] args) throws Exception { String host = "localhost"; InetAddress inetAddress = InetAddress.getByName(host); String hostName = inetAddress.getHostName(); […]
JDBC / CATATAN</>↗JDBC09 Jun 2010
This example shows you how to get the maximum number of concurrent connections to a database that are possible. To get this information, we use the DatabaseMetaData.getMaxConnections() method call. If the return value is zero, it means that there is no limit or the limit is unknown. package org.kodejava.jdbc; import java.sql.Connection; import java.sql.DatabaseMetaData; import java.sql.SQLException; […]
JDBC / CATATAN</>↗JDBC07 Jun 2010
package org.kodejava.jdbc; import java.sql.Driver; import java.sql.DriverManager; import java.sql.SQLException; public class JDBCCompliant { private static final String URL = "jdbc:mysql://localhost/kodejava"; public static void main(String[] args) { try { Driver driver = DriverManager.getDriver(URL); // Check if the driver is a genuine JDBC compliant driver. if (driver.jdbcCompliant()) { System.out.println("A genuine JDBC compliant driver"); } else { System.out.println("Not...
JDBC / CATATAN</>↗JDBC07 Jun 2010
The example below shows you how to get the information about the possible properties for the corresponding JDBC driver. package org.kodejava.jdbc; import java.sql.*; public class DriverPropertyInfoDemo { private static final String URL = "jdbc:mysql://localhost/kodejava"; public static void main(String[] args) { try { // Gets information about the possible properties for this // driver. Driver driver […]