Hi Tobias,
Login to netweaver(<protocol>://<Server>:<Port>/nwa) and navigate to the following path:
Configuration-->Infrastructure-->ApplicationResources
Here you will find all the JDBC Datasource and aliases.
Search for the alias with name "XMIIDATASOURCE". This is the JDBC DataSource Alias which MII uses for the database connections.
you can either use this or create a new alias here for you use.
I would suggest that you create a new one.
Refer to this link to see how you can use this alias in the java code to get connection object and then query the database.
Getting a Connection to the Database - Using Java - SAP Library
If you want to connect to another database all together then you need to create a JDBC Custom DataSources first and then one alias for this custom data source.
Though I have not done this myself but this should work.
Regards,
Rohit Negi.