Posts

Showing posts from February, 2013

Example AES technology

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import org.apache.commons.io.IOUtils;

public class Test {

    /**
     * @param args
     */
    public static void main(String[] args) {
          System.out.println("Listing all table name in Database!");
          Connection con = null;
          String url = "jdbc:mysql://localhost:3306/";
          String db = "test";
          String driver = "com.mysql.jdbc.Driver";
          String user = "root";
          String pass = "root";
          String name="";
          String address="";
          try{
              Class.forName(driver);
              con = DriverManager.getConnection(url+db, user, pass);
              try{
                  System.out.println("Table name:");
                  Statement st = con.createStatement();
                  Resu…

Heap size for JVM

Two JVM options are often used to tune JVM heap size: -Xmx for maximum heap size, and -Xms for initial heap size. Here are some common mistakes made by developers while using them:
Missing m, M, g or G at the end (they are case insensitive). For example,

java -Xmx128 BigApp java.lang.OutOfMemoryError: Java heap space The correct command should be: java -Xmx128m BigApp. To be precise, -Xmx128 is a valid setting for very small apps, like HelloWorld. But in real life, I guess you really mean -Xmx128m

Extra space in JVM options, or incorrectly use =. For example,

java -Xmx 128m BigApp Invalid maximum heap size: -Xmx Could not create the Java virtual machine. java -Xmx=512m HelloWorld Invalid maximum heap size: -Xmx=512m Could not create the Java virtual machine. The correct command should be java -Xmx128m BigApp, with no whitespace nor =. -X options are different than -Dkey=value system properties, where = is used.

Only setting -Xms JVM option and its value is greater than the default maxim…