By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,077 Members | 1,175 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,077 IT Pros & Developers. It's quick & easy.

JDBC-MySQL

P: n/a
Can I have the list of databases without to connect at to one of they?

...
String DRIVER = "org.gjt.mm.mysql.Driver";
String DB_URL = "jdbc:mysql://localhost/test";
Class.forName(DRIVER);
Connection connection =
DriverManager.getConnection(DB_URL,"user","passwor d");
Statement statement = connection.createStatement();
statement.execute("SHOW DATABASES");
...

In this case I want to connect to DBMS without connect to test. It's
possible?
Thanks,
--
elfoblu

--
elfoblu
Jul 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
In general no. Its not a normal part of JDBC.

That would only be possible if the MySQL driver class you're using provided
extra methods for getting a list of databases. For example,
ActualDriverClass drv = (ActualDriverClass) Class.forName(DRIVER);
String[] listOfDb = drv.getDatabases();

"eyes2ice" <ey******@gmail.com> wrote in message
news:19******************@tornado.fastwebnet.it...
Can I have the list of databases without to connect at to one of they?

...
String DRIVER = "org.gjt.mm.mysql.Driver";
String DB_URL = "jdbc:mysql://localhost/test";
Class.forName(DRIVER);
Connection connection =
DriverManager.getConnection(DB_URL,"user","passwor d");
Statement statement = connection.createStatement();
statement.execute("SHOW DATABASES");
...

In this case I want to connect to DBMS without connect to test. It's
possible?
Thanks,
--
elfoblu

--
elfoblu

Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.