Recommendation for a Java in memory database [closed]

荒凉一梦 提交于 2021-02-11 13:28:48

问题


Looking for a recommendation. I have a command line utility that now needs to process a large amount of data coming from a web service in a form of a CSV.

I need to run multiple tests on the data to look for anomalies and patterns. I'd like the utility to be something that someone can download and not have to install or configure.

Is there a recommendation for a NoSQL or SQL database that I can just spin up in memory, load the CSV into a table and then run my queries against that data?

Can Redis be used without installation? Something else?


回答1:


How about H2 Database? It's pure Java, in-memory and can be embedded into your application, see Connecting to an Embedded (Local) Database

example:

import org.h2.jdbcx.JdbcDataSource;

JdbcDataSource ds = new JdbcDataSource();
ds.setURL("jdbc:h2:˜/test.db");
ds.setUser("sa");
ds.setPassword("sa");
Connection conn = ds.getConnection();

(adapted from http://www.h2database.com/javadoc/org/h2/jdbcx/JdbcDataSource.html)

If you want an in-memory database, change URL to something like jdbc:h2:mem:test.db or similar. Look for "in-memory Databases" in documentation.




回答2:


I have not yet used it, but have a look at JasDB

From the website.

Quick Install guide

JasDB is incredibly easy to get started with it is up and running under a minute simply download and run it, or simply include it in your project Instructions

  • Install JasDB by unzipping the download
  • Start the database using start.bat or start.sh
  • Open http://localhost:7050

From https://github.com/oberasoftware/jasdb/wiki/Using-In-memory-indexes-and-storage

JasDB can run with full in memory based indexes and record storage. The following configuration needs to be used in that case:

<Storage>
    <RecordWriter provider="inmemory"/>
    <!--<RecordWriter provider="transactional"/>-->
</Storage>


来源:https://stackoverflow.com/questions/33984542/recommendation-for-a-java-in-memory-database

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!