I have made a few small programs which connects to a db to fetch some info and/or write stuff there too. They do it with the MySQL connector with the username and password hardcoded (just using the apps by myself anyway).

I read somewhere though that you shouldn't do like that if you are releasing the program to the public, you should do another way (which I can't remember what it was).

So how should I do to be able to write and read from a table in a MySQL DB with my program, safe and secure (okay not ubersecure, just better than hardcoding, for example if I want to release the source code)?