Connecting Tech Pros Worldwide Forums | Help | Site Map

JDBC-MySQL

eyes2ice
Guest
 
Posts: n/a
#1: Jul 18 '05
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



E.Otter
Guest
 
Posts: n/a
#2: Jul 18 '05

re: JDBC-MySQL


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" <eyes2ice@gmail.com> wrote in message
news:19m0e.18591$kC3.1167@tornado.fastwebnet.it...[color=blue]
> 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
>
>[/color]


Closed Thread