your question was a bit ambiguous.
if you want to create database using your java application, execute the following query: "create database <dbname>"
if you want to execute some java code when creating database, its a bit harder.
MySQL databases are created as folders in /var/lib/mysql or where ever you database path is.
watch for creation of a new directory in that folder and execute your java code when you see new directory created.