How to get the name of the database to which I am connected in MySQL with Java?

2

Hello innovative programmers, I would like to know if you can get the name of the schema or database to which I am connected when establishing the connection in MySQL with java, if you can, would you tell me how?

I already tried with DataBaseMetaData but I could not even use that object.

    
asked by Alexis Rodriguez 20.10.2016 в 10:50
source

1 answer

2

You say you used DataBaseMetaData, but did you use the getUrl () method? connection.getMetaData().getURL()

If it does not work for you, try using Catalog as explained in this SOeng answer: link

    
answered by 20.10.2016 / 10:53
source