如何将 Access 数据库与 Java 应用程序捆绑在一起
大家好,最近我使用 Microsoft Access 创建了一个包含数据库的 Java 应用程序。我已经使用 eclipse 将其打包为 jar 文件。我将 jar 文件传递给我的朋友尝试使用它。但我的朋友告诉我,那是没有数据库连接。我如何将 microsoft access 包含在 jar 文件中。这意味着当我的朋友双击 jar 文件时,它会自动配置 microsoft access 数据库?这可能吗?
Hi recently I had created a Java application included database with Microsoft Access. I had wrapped it to jar file using eclipse. I pass the jar file to my friend to try to use it. But my friend told me that that is no database connection. How can i include the microsoft access in the jar file. Which mean when my friend double click the jar file it will auto configure the microsoft access database? is that possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
首先:你的朋友有 MS Access 运行时吗,也许他需要它?他是否配置了 Microsoft Access ODBC 数据源?
请查看以下链接:Jackcess - 用于读写 MS Access 文件的 java 库(无需运行时)、SQLLite - 另一个文件 RDMS。请考虑使用 Apache Derby 项目 - 您可以将其嵌入到您的应用程序中,这会给您带来一些优势,但需要更多的工作。我不知道您想要实现什么应用程序,因此您必须自己做出选择;)。
First of all: does your friend has a MS Access runtime, maybe he needs it? Does he configured the Microsoft Access ODBC Data Source?
Please take a look at following links: Jackcess - java library for reading and writing to MS Access file (no runtime needed), SQLLite - another file RDMS. Please consider to use the Apache Derby project - you can embed it into your application what gives you some advantages but requires more work. I don't know what app you want to implement so you will have to make a choice by yourself ;).
我不这么认为。您的朋友必须从控制面板配置 odbc 连接。另外,我建议使用 derby 或 MySql 这样的数据库,而不是 MS Access,因为 odbc 驱动程序被认为有很多错误。此外,使用像 derby 这样的嵌入式数据库不需要您的朋友进行任何配置。
I don't think so. Your friend'll have to configure the odbc connection from the control panel. Also, I would suggest using a DB like derby or MySql than MS Access as the odbc driver is considered to have many bugs. Also using an embedded DB like derby wouldn't require your friend to configure anything at all.
实际上,您的应用程序不需要包访问,因为所有版本的 Windows 都包含 jet 数据库引擎的副本。换句话说,您可以使用 Windows 脚本在 Windows 计算机上打开 Access 数据库,而无需安装 MS Access。组件或数据库引擎部分是您在读取这些访问数据库文件时需要打开的全部内容。
这里有一个 Windows 脚本,用于打开 Access 数据库并将列写入文本文件:
因此,不需要在应用程序中打包或安装 jet 数据库引擎,因为该组件在 Windows 中可用。
这可能不是太重要,但我应该指出,ms 访问开发人员的工具(让您编写代码、构建表单和构建报告)与访问开发人员的数据库引擎、vb6、vb.net 之间存在明显的区别在您的情况下,Java 可以用来读取访问数据库文件。这里不需要安装 ms-access,只需要安装数据库引擎。每个 Windows 副本都包含该数据库引擎。
Actually you don't need a package access with your application, since all versions of windows include a copy of the jet database engine. In other words you can use windows scripting to open up an access database on a windows computer without having installed ms access at all. The component or database engine part is all that you need to open in read those access database files.
Here a windows script to open a access database and write a column out to a text file:
So there is no requirement to package or install the jet database engine width your application since that component is available in windows.
It's probably not too important, but I should point out that there's a distinct difference between ms access the developer's tool to let you write code, build forms, and build reports, and that of the database engine that access developers, vb6, vb.net and in your case Java can use to read an access database file. You don't need ms-access installed here, but only the database engine. That database engine is included with every copy of windows.