除了 mysql、sql 等数据库之外的存储数据的替代方案

发布于 2024-08-21 16:20:28 字数 150 浏览 7 评论 0原文

我已经在Java核心中完成了我的项目地址簿,其中我的数据存储在数据库(MySql)中。

我面临一个问题,当我在其他计算机上运行程序时,需要再次创建孔数据库。

所以请告诉我在不使用任何数据库软件(如 mysql、sql 等)的情况下存储数据的任何替代方案。

I had completed my project Address Book in Java core, in which my data is stored in database (MySql).

I am facing a problem that when i run my program on other computer than tere is the requirement of creating the hole data base again.

So please tell me any alternative for storing my data without using any database software like mysql, sql etc.

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

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

发布评论

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

评论(9

一张白纸 2024-08-28 16:20:28

您可以使用内存数据库,例如 HSQLDBDerby(又名 JavaDB) , H2, ..

所有这些都可以运行,无需安装任何额外的软件,并且可以就像另一个图书馆一样。

You can use an in-memory database such as HSQLDB, Derby (a.k.a JavaDB), H2, ..

All of those can run without any additional software installation and can be made to act like just another library.

空袭的梦i 2024-08-28 16:20:28

我建议使用可嵌入的轻量级数据库,例如 SQLite。一探究竟。
从功能页面(在SQLite的建议用途部分下):

应用程序文件格式。而不是
使用 fopen() 编写 XML 或其他
专有格式写入磁盘文件
由您的应用程序使用,使用
SQLite 数据库代替。你会避免
必须编写并排除故障
解析器,你的数据会更容易
可访问且跨平台,以及
您的更新将是事务性的。

I would suggest using an embeddable, lightweight database such as SQLite. Check it out.
From the features page (under the section Suggested Uses For SQLite):

Application File Format. Rather than
using fopen() to write XML or some
proprietary format into disk files
used by your application, use an
SQLite database instead. You'll avoid
having to write and troubleshoot a
parser, your data will be more easily
accessible and cross-platform, and
your updates will be transactional.

梦幻之岛 2024-08-28 16:20:28

StackOverflow 的全部意义在于,您不必通过电子邮件发送问题/答案:)

您可以将数据存储在文件系统、内存(使用序列化等)中,这些是数据库的简单替代品。您甚至可以使用完全在内存中运行的 HSQLDB

The whole point of StackOverflow was so that you would not have to email around questions/answers :)

You could store data in a filesystem, memory (use serialisation etc) which are simple alternatives to DB. You can even use HSQLDB which can be run completely in memory

戒ㄋ 2024-08-28 16:20:28

如果你的数据不是很大,你可以使用简单的txt文件并将所有内容存储在其中。然后加载到内存中。但这将导致改变您修改/查询数据的方式。

If you data is not so big, you may use simple txt file and store everything in it. Then load it in memory. But this will lead to changing the way you modify/query data.

陪你到最终 2024-08-28 16:20:28

mysql、sql 等数据库软件提供了实施工作方面的抽象。如果您希望避免使用相同的数据库,您可以考虑拥有自己的数据库,例如 XML 或平面文件。 XML 仍然是更好的选择,因为 XML 解析器或处理程序可用。从长远来看,将数据放入自定义数据库/平面文件中将无法管理。

你为什么不探索sqlite呢?它是基于文件的,意味着您不需要单独安装它,并且您仍然拥有标准 SQL 来检索数据或与数据交互?我认为,sqlite 将是一个更好的选择。

Database software like mysql, sql etc provides an abstraction in terms of implementation effort. If you wish to avoid using the same, you can think of having your own database like XML or flat files. XML is still a better choice as XML parsers or handlers are available. Putting your data in your customised database/flat files will not be manageable in the long run.

Why don't you explore sqlite? It is file based, means you don't need to install it separately and still you have the standard SQL to retrieve or interact with the data? I think, sqlite will be a better choice.

﹂绝世的画 2024-08-28 16:20:28

只需使用 prevayler (.org)。比使用数据库更快、更简单。

Just use a prevayler (.org). Faster and simpler than using a database.

浅语花开 2024-08-28 16:20:28

根据您的问题,我假设您希望将某种形式的持久存储存储到运行应用程序的计算机的本地文件系统中。除此之外,您还需要决定如何使用应用程序中的数据及其数量。您需要数据库吗?您要搜索不同字段的数据吗?您需要查询语言吗?数据是否足够小以适合内存中的简单数据结构?它需要有多大的弹性?这些类型问题的答案将有助于正确选择存储。您可能只需要一个简单的 CSV 文件、XML 或类似文件。有许多轻量级数据库,例如 SQLite、Berkelely DB、JavaDB 等 - 但您是否需要数据库的强大功能取决于您的要求。

I assume from your question that you want some form of persistent storage to the local file system of the machine your application runs on. In addition to that, you need to decide on how the data in your application is to be used, and the volume of it. Do you need a database? Are you going to be searching the data different fields? Do you need a query language? Is the data small enough to fit in to a simple data structure in memory? How resilient does it need to be? The answers to these types of questions will help lead to the correct choice of storage. It could be that all you need is a simple CSV file, XML or similar. There are a host of lightweight databases such as SQLite, Berkelely DB, JavaDB etc - but whether or not you need the power of a database is up to your requirements.

旧城空念 2024-08-28 16:20:28

我最近经常使用的商店是 Neo4j。它是一个图形数据库,不仅易于使用,而且完全用 Java 编写并嵌入。与 SQL 替代方案相比,我更喜欢它。

A store that I'm using a lot these days is Neo4j. It's a graph database and is not only easy to use but also is completely in Java and is embedded. I much prefer it to a SQL alternative.

空名 2024-08-28 16:20:28

除了有关嵌入式数据库的其他答案之外,我还在开发一个对象数据库,它可以直接序列化 java 对象,而不需要 ORM。它的名字是 Sofof 我在我的项目中使用它。它有许多功能,在其网站页面中有描述。

In addition of the others answers about embedded databases I was working on a objects database that directly serialize java objects without the need for ORM. Its name is Sofof and I use it in my projects. It has many features which are described in its website page.

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