HSQLDB and files in memory

Is it possible to configure HSQLDB so that files with db information are written to memory instead of using real files? I want to use hsqldb to export some data structures along with sleep mappings. However, it is not possible to write temporary files, so I need to generate the files in memory and return the stream with their contents as an answer.

Configuring hsqldb to use nio does not seem to be a solution, because there is no way to get these files before they are written to the file system.

What I think is the protocol handler for hsqldb, but has not yet found a suitable solution.

Just to describe in other words: a hack solution was to pass hsqldb to a thread or to multiple threads. Then, during his work, he recorded data in these streams. After all the data has been written, the db user can then use these streams to send over the network.

+3
source share
1 answer

Yes, of course, we use it all the time to test integration.

use as url: jdbc: hsqldb: mem: aname

see here for more details

DbUnit offers a convenient database dump method as part of its package:

    // database connection
    Class driverClass = Class.forName("org.hsqldb.jdbcDriver");
    Connection jdbcConnection = DriverManager.getConnection(
            "jdbc:hsqldb:sample", "sa", "");
    IDatabaseConnection connection = new DatabaseConnection(jdbcConnection);

    // full database export
    IDataSet fullDataSet = connection.createDataSet();
    FlatXmlDataSet.write(fullDataSet, new FileOutputStream("full.xml"));

. DbUnit FAQ . , , puropose : . , API.

+6

Source: https://habr.com/ru/post/1749130/


All Articles