How do I get a stream into an "in-memory" database created via H2DB?
I need to create a mechanism like this:
- Create a database (H2DB);
- Create tables and populate them using some data;
- Get a stream to this database;
- Send this stream via WebDAV or whatever;
I know everything except "How to get a stream to an" in-memory "database created via H2DB"?
And some explanations:
- I cannot create the file due to server restrictions;
- I need this thread to create a file;
a source to share
You can create SQL script from database using org.h2.tools.Script.execute (String url, String user, String password, OutputStream out) . This even works for in-memory databases.
You can use what is called a file system in a file system . To get the file as a stream, you will need to use the internal H2 file (org.h2.IOUtils.openFileInputStream).
a source to share
H2 supports Databases with memory using the database url jdbc:h2:mem:
.
Application: After connecting to the database, you can send requests using jdbc to get the data you want . DatabaseMetaData
can be useful for comprehensive access. The streaming format will depend on the intended purpose.
a source to share