public void openConnection(String address, String port, String dbName,
			String username, String password) throws MainException {

		try {
			Class.forName("com.mysql.jdbc.Driver");
		} catch (ClassNotFoundException e1) {
			e1.printStackTrace();
			throw new MainException("Not able to find class com.mysql.jdbc.Driver");
		}
		
		if(!isNumeric(port)){
			throw new MainException("Port number contain non-numeric character.");
		}
		
		/*
		 * Form a valid connection URL in the format of jdbc:mysql://[DBaddress]:[Port Number]/[Schema name]
		 * For example: jdbc:mysql://localhost:3306/mkyongcom
		 */
		String connectionUrl = "jdbc:mysql://" + address + ":" + port + "/" + dbName + "?zeroDateTimeBehavior=convertToNull";

		//
		try {
			dbConnection = DriverManager.getConnection(connectionUrl, username, password);
			new DBAccess(dbConnection);
		} catch (SQLException e){
			e.printStackTrace();
			throw new MainException("Failed to connect to database");
		} catch (MainException e){
			e.printStackTrace();
			throw e;
		}
	}