/**
 * 
 */
package org.mynonglam.connectdb;

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

/**
 * @author Dao
 * 
 */
public class ConnectionDTB {

	public static Connection connection = null;
	private static Connection cn = null;
	private static final String USERNAME = "user";
	private static final String PASSWORD = "khongco";
	private static final String URL = "com.mysql.jdbc.Driver";
	private static final String STRCON = "jdbc:mysql://mysql-mynonglam.jelastic.tsukaeru.net/user?setUnicode=true&characterEncoding=UTF-8";

	/**
	 * 
	 */
	public ConnectionDTB() {
		// TODO Auto-generated constructor stub
	}

	public static Connection getConnection() {
		if (cn == null) {
			try {
				Class.forName(URL);
				cn = DriverManager.getConnection(STRCON, USERNAME, PASSWORD);
			} catch (SQLException e) {
				e.printStackTrace();
			} catch (ClassNotFoundException ex) {
				ex.printStackTrace();
			}
		}

		return cn;
	}
	
	public static void main(String[] args) {
		ConnectionDTB.getConnection();
	}

}
