This is my code, this code should be execute just one time, But when my database already exist, The database created
message has been displayed!
I want to see message just when database really created, not every time.
public static boolean createDatabase() throws Exception {
String query = "CREATE DATABASE IF NOT EXISTS LIBRARY3";
Statement st = null;
Connection con = DriverManager.getConnection(dbUrl, "root", "2000");
st = con.createStatement();
if (st.executeUpdate(query) == 1) { // Then database created
JOptionPane.showMessageDialog(null, "Database created");
return true;
}
return false;
}
This code always returns true
, Why?