简体   繁体   中英

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. 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.

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 . This pure Java product can be configured to run within your app, or can run as an external database server, or both.

You might also consider Apache Derby , and SQLite.

For a specific recommendation, use the sister site: 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. 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.

Monitor your deployments to be sure you are not overburdening the machine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM