开发者

How to get stream to "in-memory" database created via H2DB?

开发者 https://www.devze.com 2022-12-27 21:43 出处:网络
I have to create such a mechanism: Create in-memory (H2DB) database; Create tables and fill them using some data;

I have to create such a mechanism:

  1. Create in-memory (H2DB) database;
  2. Create tables and fill them using some data;
  3. Get stream to that database;
  4. Send that stream via WebDAV or something else;

I know everything except that "How to get stream to "in-memory" database created via H2DB"?


And some explanations:


You can create the SQL script from a database using org.h2.tools.Script.execute(String url, String user, String password, OutputStream out). This works even for in-memory databases.

You can use the so called 'in-memory file system'. To get the file as a stream, you would need to use the internal H2 file API however (org.h2.IOUtils.openFileInputStream).


H2 supports In-Memory Databases using the database URL jdbc:h2:mem:.

Addendum: Once you connect to the database, you can submit queries using jdbc to obtain the desired data. DatabaseMetaData may be useful for comprehensive access. The streaming format will depend on the intended target.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号