-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Mufaddal wrote:
> Hi ,
>
> Can we connect a new database using the mysql driver. ?
>
> Like when we do this thru the java code:
>
> Class.forName("com.mysql.jdbc.Driver");
> ConnectionPool cp =
> DriverManager.getConnection("jdbc:mysql://localhost/cwdb?user=root");
>
> can we specify some kind of flag like createDB = true ?
>
> ConnectionPool cp =
> DriverManager.getConnection("jdbc:mysql://localhost/
> cwdb?user=root,createDB=true");
No, and there probably will never be, mostly because it's outside the
scope of what a JDBC driver should be doing.
However, you don't have to specify a database on connection, so you
could use a JDBC URL like:
jdbc:mysql://localhost/?user=root
And then issue a query:
SHOW DATABASES LIKE 'cwdb'
and if the result set is empty, issue:
CREATE DATABASE cwdb
-Mark
- --
MySQL 2003 Users Conference -> http://www.mysql.com/events/uc2003/
For technical support contracts, visit https://order.mysql.com/?ref=mmma
__ ___ ___ ____ __
/ |/ /_ __/ __/ __ \/ / Mark Matthews <mark@stripped>
/ /|_/ / // /\ \/ /_/ / /__ MySQL AB, Full-Time Developer - JDBC/Java
/_/ /_/\_, /___/\___\_\___/ Flossmoor (Chicago), IL USA
<___/ www.mysql.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.1.90 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQE+Sr8FtvXNTca6JD8RAjwNAJ9655thflma/g4Y+h523d75icFmUQCgpuny
3+q1eIec5H2mrx6mnZSdH60=
=TIRD
-----END PGP SIGNATURE-----