If you look into the Administration Module you have a flow ManageMyAccount. This has logic that does what you are looking for. So you can rewrite this flow a bit. Just make sure you have a dataview where you display the username and that the current user somehow is being passed by Datasource.
Not sure what you are looking for here but Mendix comes with a database connected automatically. Locally this is your built-in database. You can also connect to a hosted db locally for your own environment. Please check this link:
If you want to connect to another database in your app itself there are several options. F.e.: