问题
Before knowing about Inno Setup used IzPack to do my installer, due to the need to verify if the port of the service that was about to create was in use, towards a query to the database with the driver jdbc, so if the connection was valid then send a error message to change the port.
So this is the way I did before, but I do not know how to do it in Inno Setup:
try {
Class.forName("com.mysql.jdbc.Driver");
Connection conn =
DriverManager.getConnection(
"jdbc:mysql://" + server + ":" + port + "/database", "root", password);
if (conn.isValid(0)) {
error = "A server-type installation already exists in: " + server;
return Status.ERROR;
}
} catch (ClassNotFoundException ex) {
Logger.getLogger(Conexion.class.getName()).log(Level.SEVERE, null, ex);
} catch (SQLException ex) {
Logger.getLogger(Conexion.class.getName()).log(Level.SEVERE, null, ex);
}
Thank you very much.
回答1:
You will have to execute a command-line MySQL client (mysql
).
For some examples of executing an executable and checking its exit code and/or inspecting its output, see:
- Using Process Exit code to show error message for a specific File in [Run];
- How to get an output of an Exec'ed program in Inno Setup?
来源:https://stackoverflow.com/questions/44249388/mysql-query-in-inno-setup