Update gitignore foe Java, and update Java sample to clean connection and exit