I have been reading various articles online about how best to store passwords for this sort of purpose. So far the closest I have is by adding the password to a keystore file created through the command prompt. With this approach all I can do is access the SecretKey object
SecretKeyEntry entry = (KeyStore.SecretKeyEntry)ks.getEntry("vault",new KeyStore.PasswordProtection(password));
            SecretKey someKey = entry.getSecretKey();
            System.out.println(someKey.getEncoded());
This works but to access the SecretKeyEntry I have to pass the password of the keystore in as a plaintext string and call the toCharArray method. Also from this then how could I actually go about using the value to connect to MySQL.
 
     
    