How to create mysql database with username and password from java code ? and create all the tables ?
i was googling and i found this code
Conn = DriverManager.getConnection
("jdbc:mysql://localhost/?user=root&password=rootpassword");
s=Conn.createStatement();
int Result=s.executeUpdate("CREATE DATABASE databasename");
but in my case i need to :
-set a username and password from java
- create all the tables
make sure that:
MySQL charset: UTF-8 Unicode (utf8)
MySQL connection collation: utf8_general_ci
my database and table collations are set to: utf8_general_ci or utf8_unicode_ci
and after that i must execute this in mysql : SET NAMES 'utf8'
SET CHARACTER SET utf8
can i do that on java code ?