如何制作.jar文件读取数据库和序列化.txt文件?

发布于 2025-01-24 21:35:40 字数 118 浏览 4 评论 0 原文

我正在尝试从程序中使用SQLITE数据库和序列化的读/写文件系统来制作可执行的.jar文件,以存储该程序。我们能够制作一个可执行的.jar文件,但是它没有从我们在程序中编写的任何数据库或文件系统中读取。有人知道该怎么做吗?

I'm trying to make an executable .jar file from a program that uses both an SQLite database and a serialized read/write file system for storage inside the program. We are able to make an executable .jar file, but it doesn't read from any database nor file system that we have written within the program. Does anybody know how to do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

生来就爱笑 2025-01-31 21:35:41

“从数据库中读取.jar文件”当您拥有几乎完成的Java或Kotlin(或Scala)程序时。

我认为您的问题是编写一个程序需要什么。
为此,您必须考虑数据库应该能够处理的内容。

从文件系统中读取

光盘上的文本文件非常基本,但是如果应用程序只是读/写一些持久状态,则可能就足够了。为此,Java API拥有您需要的一切,请查看 baeldung- nio

从数据库中读取

如果您需要交易或支持持续存储的多个应用程序,则数据库将是更明智的方法。

尽管Java API再次为您提供所需的一切(例如)您需要从某种意义上重新发明轮子。更容易的是依靠 or-mapper 喜欢 a href =“ https://hibernate.org/orm/” rel =“ nofollow noreferrer”> hibernate 或 jooq

为了撰写企业Java软件,您可以使用

"To make a .jar file read from a database" when you have a Java or Kotlin (or Scala) program which does that you are almost done, you just have to compile it and which provides you a .jar file which does exactly that.

I think your question is what does it take to write a program that does it.
For that you have to think about what your database should be able to handle.

Read from filesystem

A text file on a disc is very rudimentary but might suffice if the application is just to read/write some persisted state. For that the Java API has all you need, take a look at Baeldung - read from file via NIO.

Read from database

If you need transactions or support for multiple applications working with the persisted storage, a database would be the more sensible thing to use.

Although the Java API again provides you everything you need for that (e.g.Processing SQL Statements with JDBC) you would need to reinvent the wheel in a sense. The easier thing would be to rely on an OR-mapper like Hibernate or JOOQ.

For writing enterprise Java software you could overengineer it with Spring-Boot JPA.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文