Not sure if you're asking if you can actually change the database name or simply get a new connection to a named database.
If you just want to connect to a named database, then just do it when you create the connection via th DriverManager.
You may want to take a look at the vendor's JDBC driver docs though as sometimes they add on little extra features that are not in the spec (or remove ones that are open to interpretation).
I seem to recall working with one awhile back that initially used the database name if it was passd in the URL when getting the Connection and then stopped using it even if it was included. They had the change documented though.
Well, if you need a list of all the schemas in the database, you can doing by means of obtaining the DatabaseMetadata.
This code will print all the schemas in the database:
However, I am not sure if there is a way to know what is the current schema. I guess it may depend on the database. For instance, in Derby, the current schema is named as the user currently signed in. So, you could obtain the current user name from the MetaData and know that is your current schema
However, not all databases are the same, I guess you will have to explore how your driver works.