public static synchronized boolean checkConnection() {
		if (closed)
			return false;
		final int timeout = 5000;
		try {
			if (conn != null && conn.isValid(timeout))
				return true;
		} catch (SQLException e) {
			// Consider as broken connection
		}

		final String url;
		{
			String url_ = "jdbc:mysql://" + Connection.db_hostname + ":"
					+ Connection.db_port + "/" + Connection.db_database
					+ "?user=" + Connection.db_username
					+ "&zeroDateTimeBehavior=convertToNull";
			if (Connection.db_password != null
					&& Connection.db_password.length() > 0)
				url_ += "&password=" + Connection.db_password;
			url = url_;
		}

		java.sql.Connection con = conn;
		try {
			con = DriverManager.getConnection(url);

			try {
				if (conn != null)
					conn.close();
			} catch (SQLException e) {
				System.err.println("Error closing existing JDBC: "
						+ e.getLocalizedMessage());
				con.close();
				return false;
			}

			// Set new connection
			conn = con;
			return true;

		} catch (SQLException e) {
			System.err.println("New JDBC Connection failed: "
					+ e.getLocalizedMessage());
			return false;
		}
	}