From within a java code - where I already have a connection to a database - I need to find the default schema of the connection.
I have the following code that gives me
Please use connection.getMetaData().getURL() method which returns String like
connection.getMetaData().getURL()
jdbc:mysql://localhost:3306/?autoReconnect=true&useUnicode=true&characterEncoding=utf8
We can parse it easily and get the schema name. It works for all JDBC drivers.