I am new to MySQL and thinking to use MySQL for my new Java Project which creates a database on the local client machine and uses it to perform all data operations. But before proceeding with MySQL I'm in a bit of doubt that I have MySQL server installed so it is working fine on my machine but what if I give this software to an end user which do not have it installed or with some other username and password. Like I have following code for creating a database, it will most probably not work on any target client machine. I know its bit of stupid question but i'm unable to think of a solution for it.
public class CreateDatabase {
public static void main(String[] args) {
Connection connection = null;
Statement statement = null;
try {
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
String url = "jdbc:mysql://localhost/mysql";
connection = DriverManager.getConnection(url, "root", "root");
statement = connection.createStatement();
String dbSQL = "CREATE DATABASE mynewdb";
statement.executeUpdate(dbSQL);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (statement != null) {
try {
statement.close();
} catch (SQLException e) {
} // nothing we can do
}
if (connection != null) {
try {
connection.close();
} catch (SQLException e) {
} // nothing we can do
}
}
}
}