Mysql
 SQL >> Database >  >> RDS >> Mysql

Ottenere il database corrente da una connessione JDBC

Connection#getCatalog() può non riflettere un USE dbname eseguito sulla stessa connessione JDBC. Per MySQL è più affidabile SELECT DATABASE().

String currentDb = con.getCatalog();
// oppure
SELECT DATABASE()