简体   繁体   English

有没有一种方法可以在不需要专用服务器的情况下使用 Java 存储信息?

[英]Is there a a way I can store information with Java without requiring a dedicated server?

By this, I simply mean that I want a program that stores its information locally in tables, on whatever computer it is running on, compared to needing to connect to a dedicated server to do so.在这里,我的意思只是说我想要一个程序将其信息本地存储在表中,无论它运行在什么计算机上,而不是需要连接到专用服务器才能这样做。 I'd prefer if there was a way to do this in SQL language.我更喜欢是否有办法用 SQL 语言来做到这一点。 I've tried looking up frameworks that do this, and haven't had any luck (maybe I'm not wording it right).我试过查找执行此操作的框架,但没有任何运气(也许我的措辞不正确)。 I do know that this is possible anyway in the .NET framework with C#, so I assumed there was a way to do it with other languages as well.我确实知道这在使用 C# 的 .NET 框架中无论如何都是可能的,所以我认为有一种方法可以用其他语言来做到这一点。

Embedded Database嵌入式数据库

If you want to use a database engine within your app locally rather than communications with an external database server, use an embedded database.如果您想在本地使用应用程序中的数据库引擎而不是与外部数据库服务器通信,请使用嵌入式数据库。

My first choice would be H2 Database Engine .我的第一选择是H2 Database Engine This pure Java product can be configured to run within your app, or can run as an external database server, or both.这个纯 Java 产品可以配置为在您的应用程序中运行,也可以作为外部数据库服务器运行,或者两者兼而有之。

You might also consider Apache Derby , and SQLite.您还可以考虑Apache Derby和 SQLite。

For a specific recommendation, use the sister site: Software Recommendations Stack Exchange .有关特定建议,请使用姊妹站点: Software Recommendations Stack Exchange

Local server本地服务器

Another option is to install a database server on the same machine as your app.另一种选择是在与您的应用程序相同的机器上安装数据库服务器。 So no network is involved.所以不涉及网络。 Your Java app would make a JDBC connection to the server but would be communicating within the same OS rather than going out over the network.您的 Java 应用程序将与服务器建立 JDBC 连接,但将在同一操作系统内进行通信,而不是通过网络进行通信。 This is much faster and more reliable than involving a network.这比涉及网络要快得多,也更可靠。

This setup is common with web apps, where the web container such as Apache Tomcat or Eclipse Jetty shares the same machine with a database server such as Postgres.这种设置在 Web 应用程序中很常见,其中 Apache Tomcat 或 Eclipse Jetty 等Web 容器与 Postgres 等数据库服务器共享同一台机器。

Monitor your deployments to be sure you are not overburdening the machine.监控您的部署以确保您不会使机器负担过重。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将常见问题解答信息存储在java .properties文件中? - How can I store faq's information in a java .properties file? Java更好的存储过程信息的方法 - Java better way to store procedural Information 在Java中存储MySQL登录信息的最佳方法 - Best way to store MySQL login information in Java 我可以使用keytool创建没有密码的Java信任库吗? - Can I create a Java trust store without a password using keytool? 为什么我可以在不丢失信息的情况下在该接口中存储实现接口的类的实例? - Why can I store an instance of a class which implements an interface “in” that interface without losing information? 专用服务器:为什么我的JAVA应用程序无法连接到我的MySQL数据库? - Dedicated server: why can't my JAVA application connect to my MySQL database? Java - 存储单个值和一条相应信息的最佳方法? - Java - Best way to store a single value and one piece of corresponding information? Java:从文件存储/检索锻炼信息的最有效方法? - Java: Most efficient way to store/retrieve workout information from a file? 为什么我不能从Java中的专用枚举值访问静态最终成员 - Why can't I access static final members from a dedicated enum value in Java 我可以在没有任何请求的情况下重定向页面到Java服务器吗? - can I redirect the page without any request to server in java?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM