Answer the question
In order to leave comments, you need to log in
How to create a MySQL DB in Java?
I
want the application to check the presence of a database at startup and, in case of absence, a script is executed to create a database (namely, a database, not tables in the created database) in MySQL.
so I connect to the db
private static final String test = "jdbc:mysql://localhost:3306?useUnicode=true&useSSL=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC&create=true";
try {
Statement statementTest = ConnectionDB.getInstance().getConnectionTest().prepareCall("create database test;");
} catch (SQLException e) {
e.printStackTrace();
}
Answer the question
In order to leave comments, you need to log in
I may be wrong, but most likely in the first script you are not connecting to the database, but simply assigning the value of the address to which the connection is made to the `test` variable. Further, in theory, you should use it as an argument in the `getConnection` method
Everything, I figured it out myself, the solution is here , if anyone needs it
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question