MySQL query in Inno Setup

与世无争的帅哥 提交于 2019-12-22 01:36:43

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!