view raw
cb0 cb0 - 9 months ago 53
MySQL Question

Create MySQL database from Java

Is there any possibility of creating a database within MySQL from Java?

I'm only aware of the

String url="jdbc:mysql://localhost:3306/test";

Connection con = DriverManager.getConnection( url, "cb0", "xxx" );

syntax, but here you have to specify a database name in the 'url'.

How can I create a MySQL database when I only have a login name and password, but no knowledge about the existing databases?


The database isn't required in the jdbc connection, so you can do something like recommended at,99321,102211#msg-102211 and

Conn = DriverManager.getConnection
int Result=s.executeUpdate("CREATE DATABASE databasename");