如何从 NSIS ping 数据库?
组装 NSIS 安装程序。 (第一次)
目前,我们安装中的手动步骤是建立到数据库的 URL 连接,并将基本连接属性文件保存到 Tomcat 下的文件夹中。
为了帮助实现这一点,我们当前使用一个小型 JAR 应用程序来帮助用户构建此连接属性文件。
它具有尝试 ping 数据库的内置功能。 它通过下拉菜单选择不同的数据库供应商/版本来帮助用户,从而帮助构建 URL。
在我的模型中,理想情况下,我想要一些能够消除 JAR 应用程序并将此组件内置到中的东西安装程序。像这样的东西:
我已经知道我需要为此创建一个自定义页面(将使用 NSISDialogDesigner 之类的东西来协助此事)。
我不确定的是,从 NSIS ping 数据库以确保提供正确的 URL/凭据并将错误返回到自定义页面的最佳方法。
在 NSIS 安装程序中实现此功能的最佳方法是什么?
对于背景,一旦我实现了这一点,后续步骤将是通过运行我拥有的一些 SQL 脚本来创建数据库。 提前思考一下,我猜他们拥有哪个数据库供应商/版本,将取决于要运行哪个 sql 脚本。我认为,如果用户在此页面上选择 SQL Server 2005,则可以将其写入一个变量,以便稍后在选择正确的 SQL 脚本时使用。
Putting together a NSIS installer. (first time)
Currently, a manual step in our install is to make a URL connection to a database, and save a basic connection properties file to a folder under Tomcat.
To aid this, we currently use a small JAR application that helps the user build this connection property file.
It has built in functionality to try and ping the DB.
It aids users by having a drop down to choose different db vendors/versions, and thus helping with building the URL.
In my mockup, ideally, I wanted something that did away with the JAR app and have this component built into the installer. Something like this:
I already know that I will need to create a custom page for this, (will use something like NSISDialogDesigner to assist with this).
The bit that I am unsure about, is the best approach for pinging the database from NSIS to ensure a correct URL/credentials has been supplied, and to return the errors back to the custom page.
What would be the best approach for implementing this functionality within a NSIS installer?
For background, once I have achieved this, a later step will be to create a database by running some SQL scripts I have.
Just thinking ahead, I guess which database vendor/version they have, will depend on which sql script to run. Im thinking that if the user chooses e.g. SQL Server 2005 on this page, this could be writen to a variable to use later when choosing the right sql script.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
实现这一目标的最佳方法是编写一个帮助器命令行应用程序,您应该在后台不可见地运行该应用程序,然后检查退出代码是否成功。这个帮助应用程序可以是 Java、C++、C# 或任何您喜欢的语言。我参与过几个非常大型的 NSIS 部署,并且在不同的设置阶段我们可能启动了 10 - 20 个这样的工具。对于单个 WIN32 API 调用,NSIS 提供了类似 P/Invoke 的包装器,但对于任何复杂的事情,帮助程序应用程序都是最佳选择。
The best way of pulling this off is to write a helper commandline application which you should run invisibly in the background and then check the exit code for success or failure. This helper app can be Java, C++, C#, or anything, whatever you're comfortable with. I've worked on several very large NSIS deployments and we had maybe 10 - 20 such tools launched during different phases of setup. For single WIN32 API calls, NSIS provides a P/Invoke-like wrapper, but for anything even remotely complicated, helper apps are the way to go.