问题描述
在了解 Inno Setup 之前,已使用 IzPack 来执行我的安装程序,因为需要验证是否要使用要创建的服务端口,以使用驱动程序jdbc对数据库进行查询,因此,如果连接有效,则发送错误消息以更改端口.
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.
这就是我以前做过的方式,但是我不知道如何在Inno Setup中做到这一点:
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);
}
非常感谢您.
推荐答案
您将必须执行命令行MySQL客户端(mysql
).
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?
这篇关于Inno Setup中的MySQL查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!